【发布时间】:2017-03-09 07:27:38
【问题描述】:
解决方案代码:
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 参数,我想不出它还能是什么。
谢谢
【问题讨论】:
-
在
center而不是类上调用该函数并提供回调处理程序developer.apple.com/reference/usernotifications/… -
你能把我的回答标记为接受吗?
-
首先确保您有授权,然后您可以安排通知。
标签: ios swift3 ios10 unusernotificationcenter