In iOS 10 werden vor allem Lösungen
'cancelAllLocalNotifications()' in iOS 10.0 veraltet wurde abgeschrieben: Verwenden UserNotifications Framework - [UNUserNotificationCenter removeAllPendingNotificationRequests]
Verwenden Sie den Code unten abbrechen Benachrichtigung und Reset-Abzeichen
Für iOS 10, zählen Swift 3,0
cancelAllLocalNotifications
von iOS 10.
@available(iOS, introduced: 4.0, deprecated: 10.0, message: "Use UserNotifications Framework's -[UNUserNotificationCenter removeAllPendingNotificationRequests]")
open func cancelAllLocalNotifications()
Sie müssen diesen Import-Anweisung hinzufügen,
import UserNotifications
Get Notification Center veraltet. Und führen Sie den Vorgang wie unter
application.applicationIconBadgeNumber = 0 // For Clear Badge Counts
let center = UNUserNotificationCenter.current()
center.removeAllDeliveredNotifications() // To remove all delivered notifications
center.removeAllPendingNotificationRequests() // To remove all pending notifications which are not delivered yet but scheduled.
Wenn Sie einzelne oder mehrere bestimmte Benachrichtigungen zu entfernen, können Sie es nach unten Methode erreichen können.
center.removeDeliveredNotifications(withIdentifiers: ["your notification identifier"])
Hoffe es hilft .. !!
Verwenden Sie cancelAllLocalNotifications? Dies ist eine Remote-Benachrichtigung. Danke für die Kommentare. – Tedha
Ops tut mir leid, ich habe mit den lokalen Benachrichtigungen verwirrt, wie ich normalerweise beide gleichzeitig benutze. – Icaro
Oder vielleicht kann dies auch helfen http://stackoverflow.com/questions/10971825/remove-remote-notifications-from-notification-center – Icaro