Badge count is persisted after deleting an app and installing it again

前端 未结 4 2248
猫巷女王i
猫巷女王i 2020-12-18 20:38

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 notifi

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-18 21:14

    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"];  }
    

提交回复
热议问题