Links
👉

Push Notifications with Firebase Cloud Messaging

Push notifications through Firebase Cloud Messaging
Push notifications are not enabled by default for all apps. If you want us to enable them in your app then email us at [email protected].

todesktop.pushNotifications.start

To start the push notifications service all you need is a sender ID.
window.todesktop.pushNotifications.start("12345678901")
If you want to automatically show notifications then you can do the following:
window.todesktop.pushNotifications.start("12345678901", {
showNotifications: true
});

todesktop.on('pushNotifications.start')

Triggered when the push notifications service is started successfully and an FCM registration token has been received.
window.todesktop.on('pushNotifications.start', (e, token) => {
console.log(`Your FCM token is: ${token}`)
});

todesktop.on('pushNotifications.receive')

Triggered when a push notifications service is received.
window.todesktop.on('pushNotifications.receive', (e, notification) => {
console.log(notification)
/**
* {
* "from": "14017693762",
* "priority": "normal",
* "notification": {
* "title": "Hello World",
* "body": "FooBar"
* },
* "collapse_key": "do_not_collapse"
* }
**/
});

todesktop.on('pushNotifications.error')

Triggered when there is an error with the push notification service.
window.todesktop.on('pushNotifications.error', (e, error) => {
// Notify user of error
});

todesktop.on('pushNotifications.tokenUpdate')

Triggered when the FCM registration token has been updated.
window.todesktop.on('pushNotifications.tokenUpdate', (e, token) => {
console.log(`Your FCM token has been updated to: ${token}`)
});