gpt4 book ai didi

swift - 取消单个 UILocalNotification

转载 作者:行者123 更新时间:2023-11-30 13:13:32 27 4
gpt4 key购买 nike

我的应用程序上有几条通知。我想要做的是,当本地通知到达时,它会从通知中心删除另一个先前已显示的通知。

我正在使用以下代码。

static func unscheduleNotification(userInfoValue: String){
if let notifications = UIApplication.sharedApplication().scheduledLocalNotifications{
for notification in notifications{
if let userInfo = notification.userInfo as? [String:String]{
if userInfo["info"] == userInfoValue{
UIApplication.sharedApplication().cancelLocalNotification(notification)
}
}
}
}
}

如果有人在这里指出正确的方向,我将不胜感激。如果可能的话。

最佳答案

我找到了解决方案。或者一种解决方案。在通知中添加一个重复间隔允许使用我正在使用并发布在问题上的方法来删除它。

我不知道这是否是正确的程序,但它确实有效。

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

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