解决方案代码
let center = UNUserNotificationCenter.current()
print(center.getPendingNotificationRequests(completionHandler: { error in
// error handling here
}))
我的原帖:
我正在尝试通过UNUserNotificationCenter获取待处理通知的列表,因为 UIApplication.shared.scheduledLocalNotifications
已被折旧 .
这是我正在使用的代码:
let center = UNUserNotificationCenter.current()
print(UNUserNotificationCenter.getPendingNotificationRequests(center))
但是这会打印“(功能)” . getPendingNotificationRequests需要一个UNUserNotificationCenter参数,我想不出它可能是什么 .
谢谢
1 回答
getPendingNotificationRequests
调用将一组请求传递给完成闭包 . 尝试这样的事情: