UNNotification: request property
The request property is the request this notification came from: the identifier, content, and trigger are all on it.
Value
- Read-only; assigning to it throws
TypeError:request is read-only. - Remote push notifications have one too; its
triggeris aUNPushNotificationTrigger, andcontent.userInfois the push payload. - It isn't the same object that was originally handed to the system, but its content is the same.
Examples
js
const center = UNUserNotificationCenter.currentNotificationCenter();
center.addEventListener('notification', (event) => {
const request = event.notification.request;
console.log(request.identifier, request.content.title);
});Effect (not verified in the simulator): When a notification arrives while the app is in the foreground, it prints the notification's identifier and title.
Corresponding iOS API
UNNotification.request.
See also
UNNotificationRequest- This class belongs to the
@nacrejs/user-notificationspackage; for installation, see Installation