ios - 如何设置 UILocalNotification 的过期时间?

标签 ios objective-c cocoa-touch uilocalnotification

我想显示一个 UILocalNotification,但它的有效期只有 24 小时。 24 小时结束后,我希望通知“过期”;也就是说:用户无法再看到过时的通知。我怎样才能做到这一点?

最佳答案

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

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

UNUserNotificationCenter.current().removeAllDeliveredNotifications()

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

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

相关文章:

ios - 应用更新时是否删除了使用 NSUserDefaults 存储的数据?

ios - View 的 hidden = yes 和 alpha = 0.0f 有什么区别

iphone - 在 UITableViewCell 上实现我自己的滑动

ios - drawViewHierarchyInRect :afterScreenUpdates: delays other animations

ios - 复杂的多线程应用程序的最佳网络解决方案是什么?

iphone - 检测在 calloutAccessoryControlTapped 委托(delegate)中点击了哪个附件 View

android - HTML 5 音频播放器和 Android/iOS

iOS-Metal : How to clear Depth Buffer ? 类似于OpenGL中的glClear(GL_DEPTH_BUFFER_BIT)

ios - 多次调用 stringByAppendingPathComponent() 会覆盖旧文件吗?

iphone - CoreData 版本控制和阻止轻量级迁移