メインコンテンツへ飛ぶ
Soon, @electron packages on npm will require Node.js 22 LTS. Read more on our blog.

pushNotifications

Process: Main

リモートのプッシュ通知サービスに登録し、通知を受け取ります。

例えば、以下は Apple のプッシュ通知サービス (APNS) を利用してプッシュ通知に登録する場合です。

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

pushNotifications.registerForAPNSNotifications().then((token)=>{
// リモート通知サーバへトークンを転送します
})

pushNotifications.on('received-apns-notification',(event, userInfo)=>{
// userInfo フィールドを元に新規 Notification オブジェクトを生成します
})

イベント

pushNotification モジュールは以下のイベントが発生します。

イベント: 'received-apns-notification' macOS

戻り値:

  • event Event
  • userInfo Record<String, any>

アプリの実行中にリモート通知を受信したときに発生します。 参考: https://developer.apple.com/documentation/appkit/nsapplicationdelegate/1428430-application?language=objc

メソッド

pushNotification モジュールには以下のメソッドがあります。

pushNotifications.registerForAPNSNotifications() macOS

戻り値 Promise<string>

Apple Push Notification サービス (APNS) にアプリを登録し、バッジ、サウンド、アラート の通知を受け取れるようにします。 登録に成功した場合、APNS のデバイストークンで Promise が解決されます。 そうでない場合、エラーメッセージとともに Promise が拒否されます。 参考: https://developer.apple.com/documentation/appkit/nsapplication/1428476-registerforremotenotificationtyp?language=objc

pushNotifications.unregisterForAPNSNotifications() macOS

APNS からの通知の受信からアプリを登録解除します。

Apps unregistered through this method can always reregister.

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

AltStyle によって変換されたページ (->オリジナル) /