gpt4 book ai didi

swift - 清除收到的 LocalNotification 通知

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

我已使用 UILocalNotification() 创建了通知,并且我正在尝试清除收到的通知,而不删除计划的其余通知。

这是我尝试使用的代码:

UIApplication.sharedApplication().applicationIconBadgeNumber = 0
UIApplication.sharedApplication().cancelAllLocalNotifications()

但是这似乎删除了所有计划,是否没有 clearRescivedNotifcations()

最佳答案

感谢@LeoDabus,我在 iOS application: how to clear notifications? 上找到了答案

将答案从 Objective-C 转换为 swift

UIApplication.sharedApplication().scheduledLocalNotifications = UIApplication.sharedApplication().scheduledLocalNotifications

这将从通知中心删除所有通知并保留所有安排。

关于swift - 清除收到的 LocalNotification 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34935012/

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