How to increase badge number when application is in background

前端 未结 3 1381
北恋
北恋 2021-02-10 18:59

I am using this code. Every thing is working fine when push notification comes but badge number does not increase when application is in background. How to solve this problem? <

3条回答
  •  死守一世寂寞
    2021-02-10 20:05

    When the application is in the background didFinishLaunchingWithOptions method never calls. For doing something when your App is in background you need to implement your logic in AppDelegate's applicationDidEnterBackground: method like.

    - (void)applicationDidEnterBackground:(UIApplication *)application{
    
    [UIApplication sharedApplication].applicationIconBadgeNumber = 2;
    }
    

提交回复
热议问题