pushNotifications
프로세스: 메인
원격 푸시 알림 서비스로부터 알림을 등록하고 수신한다.
예를 들어, 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
EventuserInfo
Record<String, any>
앱이 실행 중일 때 원격 알림을 수신하면 이 이벤트가 발생한다.
참고: https://developer.apple.com/documentation/appkit/nsapplicationdelegate/1428430-application?language=objc
메서드
pushNotification
모듈은 다음과 같은 메서드를 제공한다:
pushNotifications.registerForAPNSNotifications()
macOS
Promise<string>
를 반환한다.
애플 푸시 알림 서비스(APNS)에 앱을 등록하여 배지, 사운드, 알림을 받을 수 있도록 한다. 등록이 성공하면 Promise는 APNS 디바이스 토큰과 함께 이행된다. 등록에 실패하면 Promise는 오류 메시지와 함께 거부된다. 참고: https://developer.apple.com/documentation/appkit/nsapplication/1428476-registerforremotenotificationtyp?language=objc
pushNotifications.unregisterForAPNSNotifications()
macOS
APNS(Apple Push Notification Service)로부터 받는 알림에서 앱을 등록 해제한다.
자세한 내용은 다음 링크를 참고한다: https://developer.apple.com/documentation/appkit/nsapplication/1428747-unregisterforremotenotifications?language=objc