В прошивке 10, выше всех решений амортизируются
'cancelAllLocalNotifications()' осуждались в прошивкой 10.0: Использование UserNotifications Рамочной основе - [UNUserNotificationCenter removeAllPendingNotificationRequests]
Используйте приведенный ниже код, чтобы отменить уведомление и справка Значок числа
Для iOS 10, Swift 3.0
cancelAllLocalNotifications
осуждается от прошивки 10.
@available(iOS, introduced: 4.0, deprecated: 10.0, message: "Use UserNotifications Framework's -[UNUserNotificationCenter removeAllPendingNotificationRequests]")
open func cancelAllLocalNotifications()
Вы должны добавить оператор импорта,
import UserNotifications
Get центр уведомления. И выполнить операцию, как показано ниже
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.
Если вы хотите удалить один или несколько конкретных уведомлений, вы можете достичь его ниже способом.
center.removeDeliveredNotifications(withIdentifiers: ["your notification identifier"])
Надеюсь, это поможет .. !!
Использовать cancelAllLocalNotifications? Это удаленное уведомление. Спасибо за комментарии. – Tedha
Ops извините, я смутился с местными уведомлениями, поскольку я обычно использую оба одновременно. – Icaro
Или, может быть, это тоже может помочь http://stackoverflow.com/questions/10971825/remove-remote-notifications-from-notification-center – Icaro