2

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

5

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

1

You can clear them using setApplicationIconBadgeNumber, e.g.:

[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
answered Mar 7, 2013 at 16:32

1 Comment

This doesn't appear to remove the notifications from the Notification Center, it just removes the badge number.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.