My application has a notification section in it, and the sum of the notifications are displayed in the form of Badge Count on the app icon. When the user accesses the notifications the Badge count decreases. Suppose the User now uninstalls the build and reinstalls it, the badge count is displayed on the app icon directly even if the user hasn't opened the app. This displayed badge count is the same as it was when the app was uninstalled. The badge count should actually be displayed once the user has opened the app and accessed the notifications section.
-
I have same issue before some days ago (app on testFlight).. i don't know but i was delete and upload build of app in testFlight and also delete and reinstall app in my device and it's working for me. – iPatel Apr 29 '14 at 12:48
-
My build is present in the appstore and a new version had been submitted recently. – user3568907 Apr 29 '14 at 12:49
-
then try to delete app from device and reinstall on the device... do same as 3-4 times may be ..it's working .. :) have a good luck .:) – iPatel Apr 29 '14 at 12:51
-
1This issue happens when i delete the app and reinstall it. I can see the old Badge count without even opening the app. Once I open the app and close it, the proper Badge count is visible. – user3568907 Apr 29 '14 at 12:53
-
[UIApplication sharedApplication].applicationIconBadgeNumber = 0; did you initialise badge count ? like this – Gajendra Rawat Apr 29 '14 at 12:58
-
badge count is displaying before opening the app. – user3568907 Apr 29 '14 at 13:05
4 Answers
I have same issue before some days ago when I was tested app from testFlight.
Generally this problem might be occur when you deleted the app (while it was showing some badge number), and re-installed it again. But it difficult to says that where is actual problem.
Read what Apple's official documentation is saying.
Resetting the Push Notifications Permissions Alert on iOS The first time a push-enabled app registers for push notifications, iOS asks the user if they wish to receive notifications for that app. Once the user has responded to this alert it is not presented again unless the device is restored or the app has been uninstalled for at least a day.
If you want to simulate a first-time run of your app, you can leave the app uninstalled for a day. You can achieve the latter without actually waiting a day by setting the system clock forward a day or more, turning the device off completely, then turning the device back on.
There are some suggestion from my experience:
- OFF your notification form settings
- And set badge 0 at server side and then delete and reinstall your app from your device. - After installation is over then run app
- After run app agin delete you app from device and then reset badge at server 1 and ON your notification form settings.
Not sure but might be this will working for you. :)

- 46,010
- 16
- 115
- 137
-
1
-
-
3
-
I don't understand why this answer was upvoted. It doesn't resolve the problem even setting the system clock forward 7 days. Furthermore, we don't expect user do some weird steps like you said. – Duan Nguyen May 07 '18 at 03:04
-
@DuanNguyen I don't know why you getting hyper like you lost everything. Be cool and just read last line. By above step It was work for me that's why I wrote it. – iPatel May 19 '18 at 05:05
The badge count is maintained by the operating system, independent of the app. When an app is uninstalled (deleted), some values are retained by the operating system, including the badge count. When the app is uninstalled, no developer method or script is called. You will either have to accept this limitation, or change your app's design to rethink and overcome this problem.

- 56,823
- 9
- 150
- 195
Execute below code in didFinishLaunchingWithOptions
if (![[NSUserDefaults standardUserDefaults] objectForKey:@"is_first_time"])
{
[application cancelAllLocalNotifications];
// Restart the Local Notifications list
application.applicationIconBadgeNumber = 0;
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES] forKey:@"is_first_time"]; }

- 71
- 1
- 4
Run freshInstallationCheck function in didFinishLaunchingWithOptions section.
func freshInstallationCheck() {
let defaults = UserDefaults.standard
guard let currentAppVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String else { return }
guard let previousVersion = defaults.string(forKey: "appVersion") else {
// Key does not exist in UserDefaults, must be a fresh install
print("fresh install")
// Writing version to UserDefaults for the first time
defaults.set(currentAppVersion, forKey: "appVersion")
// reinstall application, force to set icon to zero
UIApplication.shared.applicationIconBadgeNumber = 0
return
}
let comparisonResult = currentAppVersion.compare(previousVersion, options: .numeric, range: nil, locale: nil)
switch comparisonResult {
case .orderedSame:
// nothing to do
break
case .orderedAscending, .orderedDescending:
// new version update or downgrade
break
}
// Updating new version to UserDefaults
defaults.set(currentAppVersion, forKey: "appVersion")
}

- 1