App badge doesn't change when using PushKit framework pushes

时间:2016-04-04 17:28:36

标签: ios objective-c notifications apple-push-notifications pushkit

Since I switched to using PushKit framework for application, there are no app badge changes on push received.

Changes to APNS implementation I've done to use PushKit :

  • On server side, I replaced APNS certificates with VOIP push certificates.

  • On client side, I replaced:

    1. registerForRemoteNotifications with

      PKPushRegistry *pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
      
      pushRegistry.delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
      pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];`
      
    2. didRegisterForRemoteNotificationsWithDeviceToken and didFailToRegisterForRemoteNotificationsWithError with didUpdatePushCredentials
    3. didReceiveRemoteNotification and didReceiveRemoteNotification FetchComplitionHandler with didReceiveIncomingPushWithPayload

As a result, didReceiveIncomingPushWithPayload gets called, and I see valid badge number in payload dictionary, but, unfortunately app badge doesn't change.

1 个答案:

答案 0 :(得分:0)

In your method didReceiveRemoteNotification, you should update the badge number yourself by setting it like this:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    [application setApplicationIconBadgeNumber:1];
}