pushNotifications¶
进程:主进程
注册并接收来自远程推送通知服务的通知
例如,通过 Apple 推送通知服务(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
})
事件¶
pushNotification 模块会发出以下事件:
事件:'received-apns-notification' macOS¶
返回值:
eventEventuserInfoRecord\<String, any>
当应用运行时收到远程通知时发出。 参见:https://developer.apple.com/documentation/appkit/nsapplicationdelegate/1428430-application?language=objc
方法¶
pushNotification 模块具有以下方法:
pushNotifications.registerForAPNSNotifications() macOS¶
返回 Promise<string>
将应用注册到 Apple 推送通知服务(APNS),以接收徽章、声音和提醒通知。如果注册成功,Promise 将解析为 APNS 设备令牌。否则,Promise 将因错误消息而拒绝。 参见:https://developer.apple.com/documentation/appkit/nsapplication/1428476-registerforremotenotificationtyp?language=objc
pushNotifications.unregisterForAPNSNotifications() macOS¶
将应用从 APNS 接收的通知中注销。
通过此方法注销的应用始终可以重新注册。
参见:https://developer.apple.com/documentation/appkit/nsapplication/1428747-unregisterforremotenotifications?language=objc
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 el/electron