1

Is it possible to update application badge count by receiving a silent push.

When the application is not running in the background, this method is not called. My guess is this method get called even if the app is not running in the background. Am I wrong?

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
        fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler
{
    int currentBadge = [UIApplication sharedApplication].applicationIconBadgeNumber;
    DLog(@"%@, badge = %i", userInfo, currentBadge);
    [UIApplication sharedApplication].applicationIconBadgeNumber = [UIApplication sharedApplication].applicationIconBadgeNumber + 1;
    completionHandler(UIBackgroundFetchResultNoData);
}

I just want to increase badge number with any received notification. The notification payload do not have a "badge' field.

Is it possible?

And if the app does not run background, UIApplicationExitsOnSuspend = YES, I wonder in this situation will silent push work or not?

karim
  • 15,408
  • 7
  • 58
  • 96
  • OK. Seems like the app must run in the background to get silent notification. content-available = 1, will not run the app in the background and called delegate method. Aslo I must have UIApplicationExitsOnSuspend = NO to make all these work. – karim Feb 02 '18 at 14:30

0 Answers0