Push notifications are not enabled by default for all apps. If you want us to enable them in your app then email us at hi@todesktop.com.
To start the push notifications service all you need is a sender ID.
window.todesktop.pushNotifications.start("12345678901")
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}`)});
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"* }**/});
Triggered when the push notifications service is started successfully and an FCM registration token has been received.
window.todesktop.on('pushNotifications.error', (e, error) => {// Notify user of error});
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}`)});