因为UILocalNotification现在已弃用,所以我将代码移至新的UNNotificationRequestAPI。
它指出:“ cancelLocalNotification ”在 iOS 10.0 中已被弃用:使用 UserNotifications 框架的-[UNUserNotificationCenter removePendingNotificationRequestsWithIdentifiers:]
但似乎它并不相等 - 虽然我可以随时删除消息cancelLocalNotification(即使它们被显示/传递),但似乎removePendingNotificationRequestsWithIdentifiers只会删除未传递的通知。这真的很烦人。
所以我的问题是:是否有有效的方法删除排队的通知,UNNotificationRequest或者我应该忽略那些弃用警告?