push-notifications.md 1.8 KB

pushNotifications

Process: Main

Register for and receive notifications from remote push notification services

For example, when registering for push notifications via Apple push notification services (APNS):

const { pushNotifications, Notification } = require('electron')

pushNotifications.registerForAPNSNotifications().then((token) => {
  // forward token to your remote notification server
})

pushNotifications.on('received-apns-notification', (event, userInfo) => {
  // generate a new Notification object with the relevant userInfo fields
})

Events

The pushNotification module emits the following events:

Event: 'received-apns-notification' macOS

Returns: