我需要从通知中心删除特定的通知。
在我的应用中,我使用这种方法打开一种特殊的通知
let center = UNUserNotificationCenter.current()
center.getDeliveredNotifications(completionHandler: { (notificationRequests) in
for x in notificationRequests {
print(x.request.content.userInfo)
}
})
因此我想在阅读后删除该通知。
最佳答案
每个通知都有一个标识符,阅读通知后,您可以简单地-
UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: [notification_identifier_here])
关于ios - 从通知中心托盘中删除特定的推送通知,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53408448/