gpt4 book ai didi

ios - 取消 UNNotificationRequest

转载 作者:可可西里 更新时间:2023-11-01 00:56:43 24 4
gpt4 key购买 nike

因为 UILocalNotification 现已弃用,我将我的代码移至新的 UNNotificationRequest API。

它声明:'cancelLocalNotification' 在 iOS 10.0 中被弃用:使用 UserNotifications Framework 的 -[UNUserNotificationCenter removePendingNotificationRequestsWithIdentifiers:]

但它似乎不相等 - 虽然我可以随时使用 cancelLocalNotification 删除消息(即使它们已显示/发送),但似乎 removePendingNotificationRequestsWithIdentifiers 只会删除未送达的通知。这真的很烦人。

所以我的问题是:有没有一种有效的方法可以删除使用 UNNotificationRequest 排队的通知,或者我应该忽略那些弃用警告?

最佳答案

您还可以使用 removeDeliveredNotifications(withIdentifiers:) 函数从通知中心删除已发送的通知。有关详细信息,请参阅 documentation

关于ios - 取消 UNNotificationRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45635400/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com