首页 > 解决方案 > 判断是否触发了本地通知

问题描述

2个我找不到答案的问题:

1:如何判断是否触发了本地通知?

2:本地通知被触发后是否被删除?

标签: iosswiftuilocalnotification

解决方案


您不应该使用 UILocalNotification。现代方式是UNNotification。

您可以检查 UNUserNotificationCenter 的内容。称呼

getPendingNotificationRequests(completionHandler:)

getDeliveredNotifications(completionHandler:)

已发送但尚未从通知中心删除的通知(历史记录)在第二组中。


推荐阅读