解决方案代码
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参数,我想不出它可能是什么.
谢谢
解决方法
getPendingNotificationRequests调用将一组请求传递给完成闭包.尝试这样的事情:
let center = UNUserNotificationCenter.current() center.getPendingNotificationRequests(completionHandler: { requests in for request in requests { print(request) } })
原文地址:https://www.jb51.cc/iOS/332782.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。