Ir para o conteúdo principal


Processo: 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


O módulo pushNotification emite os seguintes eventos:

Event: 'received-apns-notification' macOS


  • event Event
  • userInfo Record<String, any>

Emitted when the app receives a remote notification while running. See:


O módulo pushNotification tem os seguintes métodos:

pushNotifications.registerForAPNSNotifications() no macOS

Retorna Promise<string>

Registers the app with Apple Push Notification service (APNS) to receive Badge, Sound, and Alert notifications. If registration is successful, the promise will be resolved with the APNS device token. Otherwise, the promise will be rejected with an error message. See:

pushNotifications.unregisterForAPNSNotifications() no macOS

Unregisters the app from notifications received from APNS. See: