I need to clear all notifications from my notification centre.I tried to cancellAllLocalNotification
and UIApplication.shared.applicationIconBadgeNumber = 0
but its not working.i am using swift 4 and xcode 10.1 and ios 12.Anyone can help me..
cancellAllLocalNotification
is deprecated from iOS 10. from appledoc
Deprecated
Use the UNUserNotificationCenter class to schedule local notifications instead.
Use
UNUserNotificationCenter.current().removeAllDeliveredNotifications() // For removing all delivered notification
UNUserNotificationCenter.current().removeAllPendingNotificationRequests() // For removing all pending notifications which are not delivered yet but scheduled.
From Delivered Removal appledoc
Use this method to remove all of your app’s delivered notifications from Notification Center. The method executes asynchronously, returning immediately and removing the identifiers on a background thread. This method does not affect any notification requests that are scheduled, but have not yet been delivered.
From Pending Removal appledoc
This method executes asynchronously, removing all pending notification requests on a secondary thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With