pushNotifications | Electron
https://www.electronjs.org/docs/latest/api/push-notifications • 40 KB fetched Open original page
pushNotifications | Electron
Skip to main content
Electron Docs API Blog Tools
* Electron Forge
* Electron Fiddle
Community
* Governance
* Showcase
* Resources
Releases English
* English
* Deutsch
* Español
* Français
* 日本語
* Português
* Русский
* 中文
Search
* Main Process Modules
* app
* autoUpdater
* BaseWindow
* BrowserView
* Deprecated
* BrowserWindow
* clipboard
* contentTracing
* crashReporter
* desktopCapturer
* dialog
* globalShortcut
* ImageView
* inAppPurchase
* ipcMain
* Menu
* MenuItem
* MessageChannelMain
* MessagePortMain
* nativeImage
* nativeTheme
* net
* netLog
* Notification
* powerMonitor
* powerSaveBlocker
* process
* protocol
* pushNotifications
* safeStorage
* screen
* session
* sharedTexture
* ShareMenu
* shell
* systemPreferences
* TouchBar
* Tray
* utilityProcess
* webContents
* WebContentsView
* webFrameMain
* View
* Renderer Process Modules
* Utility Process Modules
* Custom DOM Elements
* Chromium and Node.js
* Classes
* API Structures
*
* Main Process Modules
* pushNotifications On this page
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
Edit this page
Previous
protocol
Next
safeStorage
* Events
* 'received-apns-notification'
* Methods
* registerForAPNSNotifications
* unregisterForAPNSNotifications
Docs
* Getting Started
* API Reference
Checklists
* Performance
* Security
Tools
* Electron Forge
* Electron Fiddle
Community
* Governance
* Resources
* Bluesky
* X
* Mastodon
* Stack Overflow
More
* GitHub
* Open Collective
* Infrastructure Dashboard
Copyright OpenJS Foundation and Electron contributors. All rights reserved. The OpenJS Foundation has registered trademarks and uses trademarks. For a list of trademarks of the OpenJS Foundation , please see our Trademark Policy and Trademark List . Trademarks and logos not indicated on the list of OpenJS Foundation trademarks are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them. The OpenJS Foundation | Terms of Use | Privacy Policy | Bylaws | Code of Conduct | Trademark Policy | Trademark List | Cookie Policy
Hosting and infrastructure graciously provided by
Links found on this page
- Skip to main content [direct]
- Electron [direct]
- Docs [direct]
- API [direct]
- Blog [direct]
- Electron Forge [direct]
- Electron Fiddle [direct]
- Governance [direct]
- Showcase [direct]
- Resources [direct]
- Releases [direct]
- Deutsch [direct]
- Español [direct]
- Français [direct]
- 日本語 [direct]
- Português [direct]
- Русский [direct]
- 中文 [direct]
- autoUpdater [direct]
- BaseWindow [direct]
- BrowserView Deprecated [direct]
- BrowserWindow [direct]
- clipboard [direct]
- contentTracing [direct]
- crashReporter [direct]
- desktopCapturer [direct]
- dialog [direct]
- globalShortcut [direct]
- ImageView [direct]
- inAppPurchase [direct]
- ipcMain [direct]
- Menu [direct]
- MenuItem [direct]
- MessageChannelMain [direct]
- MessagePortMain [direct]
- nativeImage [direct]
- nativeTheme [direct]
- net [direct]
- netLog [direct]
- Notification [direct]
- powerMonitor [direct]
- powerSaveBlocker [direct]
- process [direct]
- protocol [direct]
- safeStorage [direct]
- screen [direct]
- session [direct]
- sharedTexture [direct]
- ShareMenu [direct]
- shell [direct]
- systemPreferences [direct]
- TouchBar [direct]
- Tray [direct]
- utilityProcess [direct]
- webContents [direct]
- WebContentsView [direct]
- webFrameMain [direct]
- View [direct]
- Custom DOM Elements [direct]
- Chromium and Node.js [direct]
- Classes [direct]
- API Structures [direct]
- Main [direct]
- https://developer.apple.com/documentation/appkit/nsapplicationdelegate/1428430-application?language=objc [direct]
- Badge, Sound, and Alert [direct]
- https://developer.apple.com/documentation/appkit/nsapplication/1428476-registerforremotenotificationtyp?language=objc [direct]
- https://developer.apple.com/documentation/appkit/nsapplication/1428747-unregisterforremotenotifications?language=objc [direct]
- Edit this page [direct]
- Performance [direct]
- Security [direct]
- Bluesky [direct]
- X [direct]
- Mastodon [direct]
- Stack Overflow [direct]
- GitHub [direct]
- Open Collective [direct]
- Infrastructure Dashboard [direct]
- OpenJS Foundation [direct]
- Trademark Policy [direct]
- Trademark List [direct]
|
|