How do I bring the app icon number to 0? (Using parsing and swift)

When I am about to send a push notification to my application from parsing, it has the option to enlarge the application icon. If I turn it on and send a notification, the app icon keeps going higher and higher. How do I get the badge to go back to 0? See Image here.

Note. If the answer is in the code, please respond quickly.

enter image description here

+3


source to share


2 answers


Swift

UIApplication.sharedApplication().applicationIconBadgeNumber = 0

Objective-C

[UIApplication sharedApplication].applicationIconBadgeNumber = 0;



UPDATE

to let PARSE know that it should reset the counter to do the following (this also resets the number of local icons on the device):

PFInstallation *currentInstallation = [PFInstallation currentInstallation];
if (currentInstallation.badge != 0) {
  currentInstallation.badge = 0;
  [currentInstallation saveEventually];
}

      

+8


source


   PFInstallation *currentInstallation = [PFInstallation currentInstallation];
currentInstallation.badge = 0;
[currentInstallation saveEventually];

      

Try it.



The code mentioned above changes the number of app icons but doesn't update it on the server. Therefore, when the app receives a new notification, the number of the previous icon is incremented.

+3


source







All Articles