1. Miscellaneous
  2. Send Native Notifications

Miscellaneous

Send Native Notifications

Notifications are only available in secure contexts (HTTPS).

You can send notifications to your users with the HTML5 Notifications API. We intercept the notification and send a native OS notification to your user instead.

When sending a notification in a ToDesktop app is you do not have to request permission first with the Notification.requestPermission() method as you would in a web app.

If you only want to send notifications in your Desktop app you can check if the window.todesktop object is present:

        import { platform } from '@todesktop/client-core';

if (platform.todesktop.isDesktopApp()) {
  const notification = new Notification('Welcome to our desktop app.');
}

      

Extra Features

ToDesktop also adds new features to HTML5 Notifications

Custom sounds

You can specify a custom sound to be played when your notification is shown

        new Notification('Hello world', {
  sound: './notification.mp3'
});