Files
electron/docs/api/push-notifications.md
T
claude[bot]andClaude 2954493d46 docs: fix incorrect heading levels (#55407)
Several API entries were one heading level too deep relative to their
sibling events and methods, or skipped a level under their section.


Claude-Session: https://claude.ai/code/session_01KX1hkKfxeSmmXK7rv1wNCE

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-27 17:47:53 -07:00

1.9 KiB

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:

  • event Event
  • userInfo Record<String, any>

Emitted when the app receives a remote notification while running. See: https://developer.apple.com/documentation/appkit/nsapplicationdelegate/1428430-application?language=objc

Methods

The pushNotification module has the following methods:

pushNotifications.registerForAPNSNotifications() macOS

Returns 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: https://developer.apple.com/documentation/appkit/nsapplication/1428476-registerforremotenotificationtyp?language=objc

pushNotifications.unregisterForAPNSNotifications() macOS

Unregisters the app from notifications received from APNS.

Apps unregistered through this method can always reregister.

See: https://developer.apple.com/documentation/appkit/nsapplication/1428747-unregisterforremotenotifications?language=objc