IOS/Objective-C: Get list of pending notifications from notification center

谁都会走 提交于 2019-12-12 04:09:26

问题


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)")
}

来源:https://stackoverflow.com/questions/46414436/ios-objective-c-get-list-of-pending-notifications-from-notification-center

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!