I need to clear push notifications from notification center after the user read them. I know there is cancelAllLocalNotifications method, but how do I clear all remote notifications? As an addition I would like to have the following functionality, if user has 5 messages in notification center, we clear all notifications only after user reads All of them. Any ideas how these can be implemented? Thanks in advance for any help.
asked Mar 7, 2013 at 16:29
2 Answers 2
If you want to clear notifications in swift
import UserNotifications
if #available(iOS 10.0, *) {
let center = UNUserNotificationCenter.current()
center.removeAllPendingNotificationRequests() // To remove all pending notifications which are not delivered yet but scheduled.
center.removeAllDeliveredNotifications() // To remove all delivered notifications
}
answered Jan 11, 2017 at 6:45
Sign up to request clarification or add additional context in comments.
Comments
You can clear them using setApplicationIconBadgeNumber, e.g.:
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
answered Mar 7, 2013 at 16:32
1 Comment
Andrew
This doesn't appear to remove the notifications from the Notification Center, it just removes the badge number.
default