Clear badge count without removing notifications from notification center?

So I've read that to clear notifications out of the notification center, you simply use

setApplicationIconBadgeNumber
and set the value to 0. What if we wanted to clear the badge count without clearing the notification center messages? Is there a way to clear the badge count without removing the notifications?

Accepted Reply

Figured it out, the solutionw as to set the value to -1

Replies

Figured it out, the solutionw as to set the value to -1

Hi,


@tlindeman, with which iOS version have it worked? I have tried with an iOS8 and it doesn't works (at least for me) :S


Thank you

I've also tried this solution on iOS 9 and it doesn't work. Is there another way to achieve this? In my app, there could be a lot of push notifications, but I don't want to be showing the badge number forever. But notifications are useful, so we don't want to loose them either. Any help would be appreciated. Thanks!

This does not work anymore since iOS 11 (tested with iOS 11.1). Is there a solution?

Hmm, not work for me, test device: iOS10.3.3, 5s.

For those coming here recently. Scroll down to bottom, I have confirmed the Scene Phase SwiftUI version works. Xcode 13.4, Swift 5.

I did a Switch of the newPhase as i had to address the .inactive as well as the .active. Used break on the other 2 cases, let Xcode populate them on the Fix from error it throws.