Don*_*yck 1 push-notification ios
用户阅读后,我需要从通知中心清除推送通知。我知道有 cancelAllLocalNotifications 方法,但是如何清除所有远程通知?作为补充,我想有以下功能,如果用户在通知中心有 5 条消息,我们只有在用户阅读所有消息后才清除所有通知。任何想法如何实施?在此先感谢您的帮助。
如果您想快速清除通知
import UserNotifications
if #available(iOS 10.0, *) {
let center = UNUserNotificationCenter.current()
center.removeAllPendingNotificationRequests() // To remove all pending notifications which are not delivered yet but scheduled.
center.removeAllDeliveredNotifications() // To remove all delivered notifications
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2003 次 |
| 最近记录: |