我们可以从通知列表中删除通知吗?

时间:2018-07-23 11:57:29

标签: ios swift unusernotificationcenter

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)
        }

0 个答案:

没有答案