Search code examples
iospush-notificationapple-push-notificationspushbadge

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!


Solution

  • 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];