0

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 Answers1

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];
}
emotality
  • 12,795
  • 4
  • 39
  • 60
  • when I used APNS and `didReceiveRemoteNotification`, app badge was set automatically, now I'm using `didReceiveIncomingPushWithPayload` from PK framework, and expected the same behaviour. – Yulian Baranetskyy Apr 04 '16 at 17:59
  • 1
    Well you can still use `setApplicationIconBadgeNumber` to set the badge number. If it doesn't set it automatically you can make if statements to figure out what the number should be? – emotality Apr 04 '16 at 18:01
  • Yes, I can do it manually, but I thought that it should be done automatically, I see that badge number come valid from server – Yulian Baranetskyy Apr 04 '16 at 18:03
  • So take that payload and then set the badge number? IDK whats so difficult lol :P https://developer.apple.com/library/ios/documentation/PushKit/Reference/PKPushPayload_Class/index.html#//apple_ref/occ/instp/PKPushPayload/dictionaryPayload – emotality Apr 04 '16 at 19:23