1

I am using subscriptions and notifications on CloudKit.

let notificationInfoUpdate = CKNotificationInfo()
    notificationInfoUpdate.alertBody = "There is something for you"
    notificationInfoUpdate.shouldBadge = true

The code bellow seems to be commonsense here on StackOverflow on how to reset the badge number and I applying it to my applicationDidBecomeActive.

application.applicationIconBadgeNumber = 0
//application.applicationIconBadgeNumber = -1
application.cancelAllLocalNotifications()

It is partially working. If I open the application and then close it the badge is gone.

But as soon as I receive another notification the badge goes back to 60 something... instead of starting from 0.

So in fact it is not really reseting it, but just hiding it think. Any idea?

GuiSoySauce
  • 1,763
  • 3
  • 24
  • 37
  • It's definitely resetting - look at the notification you're receiving, as it will contain the new badge number. – sschale May 31 '16 at 04:00
  • Yes, it does hide the badge, but do not reset it's. number in my case. As soon as the badge comes back with another notification it shows the previous value. I am already on badge 135 even after reseting it every time with the code above. Am I really doing it wrong or I got stuck on a bug? – GuiSoySauce May 31 '16 at 10:31
  • 5
    Found another answer at [CloudKit won't reset my badge count to 0](http://stackoverflow.com/questions/25120070/cloudkit-wont-reset-my-badge-count-to-0) and is does solve my problem. Should I delete my question? Or admins will mark it as a duplicate? – GuiSoySauce May 31 '16 at 19:56
  • @GuiSoySauce In this case, you can vote to close as duplicate :) – Antzi Jun 01 '16 at 01:56

1 Answers1

1

Well. This works as intended.

The count value on the notification badge is set by the server which send the notification. Your only option is to change this parameter server side.

Antzi
  • 12,831
  • 7
  • 48
  • 74