IOS 10 How to view the list of pending notifications using UNUserNotificationCenter?

Solution Code:

let center = UNUserNotificationCenter.current() print(center.getPendingNotificationRequests(completionHandler: { error in // error handling here })) 

My original post:

I am trying to get a list of pending notifications through the UNUserNotificationCenter, since UIApplication.shared.scheduledLocalNotifications been discounted.

This is the code I'm using:

 let center = UNUserNotificationCenter.current() print(UNUserNotificationCenter.getPendingNotificationRequests(center)) 

However, it prints "(Function)". getPendingNotificationRequests requires the UNUserNotificationCenter parameter, and I can't think about what else could be.

thanks

+5
source share
1 answer

The getPendingNotificationRequests call passes an array of requests to complete the close. Try something like this:

 let center = UNUserNotificationCenter.current() center.getPendingNotificationRequests(completionHandler: { requests in for request in requests { print(request) } }) 
+14
source

Source: https://habr.com/ru/post/1258848/


All Articles