ScottOBot
ScottOBot

Reputation: 849

iOS - Application Badge Disappears When Opened

I currently have an application that receives the correct badge number via push notification. The backend server keeps track of the number of unread updates and sends the number in a push notification when an event happens. The application badge number is then automatically set. When the user clicks on a specific part of the application the badge count is decremented and synched with the backend. This should all work in theory. However, I can't seem to make the badge stay after the user opens the application after receiving the initial push. How do I make the number stay, I looked into the issue and solving it using local notifications with the information located here: iOS badge number live update but I am hoping to use a simpler solution. Thanks for the help!

Upvotes: 0

Views: 1579

Answers (2)

Amir Hajiha
Amir Hajiha

Reputation: 935

In my case, it was because I was using Airship's SDK and instead of using their code for updating the badge count, I was using the iOS native code and that caused a glitch, especially right after a reinstallation and grant the push perms again.

Also, they have a reset method so if you are using them or any other library and that library has such capability, I would strongly advise against manually touching iOS push delegates, setting badge count number the classic way, etc. and seek to use the SDK's implementation instead.

Upvotes: 0

CW0007007
CW0007007

Reputation: 5681

In your application delegate, do you have any code that is clearing the badge count i.e.

[UIApplication sharedApplication].applicationIconBadgeNumber = 0;

||

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];

Upvotes: 3

Related Questions