OGeek|极客世界-中国程序员成长平台

标题: ios - 如何设置 UILocalNotification 的过期时间? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 20:25
标题: ios - 如何设置 UILocalNotification 的过期时间?

我想显示一个 UILocalNotification,但它只会在 24 小时内有效。在 24 小时结束时,我希望通知“过期”;即:用户不能再看到过时的通知。我该怎么做?



Best Answer-推荐答案


要取消已发送的通知,请使用

UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: ["myidentifier"])

UNUserNotificationCenter.current().removeAllDeliveredNotifications()

此答案中的示例代码:https://stackoverflow.com/a/45218609/2650588

关于ios - 如何设置 UILocalNotification 的过期时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7957502/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4