UNUserNotificationCenter: getPendingNotificationRequests() method
The getPendingNotificationRequests() method reads notifications that have been handed to the system but not yet delivered.
Syntax
getPendingNotificationRequests()Parameters
None.
Return value
A Promise that fulfills with an array of UNNotificationRequest.
- Notifications delivered immediately (without
trigger) do not appear here (not verified in the simulator). - The requests read back are not the same objects originally handed over, though their contents are the same. Compare by
identifier. - Notifications just withdrawn may still be included; see
removePendingNotificationRequestsWithIdentifiers().
Exceptions
None.
Examples
js
const center = UNUserNotificationCenter.currentNotificationCenter();
const requests = await center.getPendingNotificationRequests();
console.log(requests.map((request) => request.identifier).join(', '));Effect (not verified in the simulator): logs the identifiers of all notifications not yet delivered.
Corresponding iOS API
-[UNUserNotificationCenter getPendingNotificationRequestsWithCompletionHandler:]. The completion handler is replaced by a promise.
See also
UNNotificationTrigger: telling trigger types apart withinstanceof- This class belongs to the
@nacrejs/user-notificationspackage; see Install first