ios – UNUserNotificationCenter.current().getDeliveredNotifi
发布时间:2020-12-14 17:52:22 所属栏目:百科 来源:网络整理
导读:基本上,我只是尝试打印我的应用程序提供的通知,但执行以下操作: UNUserNotificationCenter.current().getDeliveredNotifications { (notifications) in print(notifications)} 只是在Xcode控制台中显示一个空数组,即使通知中心包含多个已发送的通知. (print
基本上,我只是尝试打印我的应用程序提供的通知,但执行以下操作:
UNUserNotificationCenter.current().getDeliveredNotifications { (notifications) in print(notifications) } 只是在Xcode控制台中显示一个空数组,即使通知中心包含多个已发送的通知. (print(notifications.count)返回0) 我可以使用getPendingNotificationRequests成功获取已安排但尚未传递的通知,更新它们,甚至使用removePendingNotificationRequests(withIdentifiers :)删除它们.但任何访问/修改/删除任何已交付的东西的尝试都不起作用. 我错过了一些简单的东西吗?最近iOS 10访问已发送通知的方式有什么变化吗? 解决方法
我确实遇到了与getDeliveredNotification相同的问题,通知数组总是空的.
所以,我意识到我将[UIApplication sharedApplication] .applicationBadgeNumber设置为0,清除了来自通知中心的所有远程通知. 现在,只有在我收到所有待处理通知后,才将applicationBadgeNumber设置为0. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |