我found here非常有趣。它正在从通知面板中删除“远程”通知。
我只是查找/阻止某些远程通知被接收。 我们如何实现这一目标?
我用过UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers:
,但这没用。
UNUserNotificationCenter.current().getPendingNotificationRequests { (notificationRequests) in
var identifiers: [String] = []
print("notificationRequests----",notificationRequests)//gives []
for notification:UNNotificationRequest in notificationRequests {
print("notification----",notification)
if notification.identifier == "identifierCancel" {
identifiers.append(notification.identifier)
}
}
UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: identifiers)
}