IOS/Objective-C: Get list of pending notifications

2019-08-22 04:02发布

问题:

I am trying to get list of local notifications for my app that are in the notification center so I can display these in the app.

I found this code in this SO answer but it is in Swift. Can anyone translate to Objective-C or suggest how to get the notifications that have fired but are pending in Objective-C?

if #available(iOS 10.0, *) {           
    UNUserNotificationCenter.current().getPendingNotificationRequests { (requests) in
        print("here are the iOS 10 notifs \(requests)")
    }         
} else {
    let requests = (UIApplication.shared.scheduledLocalNotifications ?? [])
    print("here are the NON iOS 10 notifs \(requests)")
}