【发布时间】:2016-11-03 09:10:41
【问题描述】:
我想在添加新通知时从 NotificationCenter 中删除所有以前的本地通知。但它在 iOS9.0 及更低版本中工作,但在 iOS 10 中它会触发多个本地通知。所以看起来cancelAllLocalNotifications 没有清除通知。
iOS10代码编译成功
UIApplication.shared.cancelAllLocalNotifications()
【问题讨论】:
-
对于iOS10的通知,你用的是什么?你在使用“UserNotifications”框架吗?
-
是的,我正在使用
UNUserNotifications框架 -
有趣,
cancelAllLocalNotifications()在 iOS 10.2 中为我工作。 -
cancelAllLocalNotifications()为我工作,直到我链接了 iOS 10 的 UserNotification 框架。通过该链接,我可以使用旧 API 发布本地通知,但取消全部停止工作。
标签: ios swift uilocalnotification ios10