Search code examples
iosobjective-capple-push-notificationsdevicetoken

Always not getting the device token from the didRegisterForRemoteNotificationsWithDeviceToken delegate of UIApplication


I need device token to implement push notification in my app as before I am getting the device token from didRegisterForRemoteNotificationsWithDeviceToken method but recently it does not work.

For more information please find the below code in didFinishLaunchingWithOptions method.

if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
      UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge
          |UIRemoteNotificationTypeSound
          |UIRemoteNotificationTypeAlert) categories:nil];
      [application registerUserNotificationSettings:settings];
} else {
      UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
      [application registerForRemoteNotificationTypes:myTypes];
}

And also I had added the delegate didRegisterUserNotificationSettings.

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
  if (notificationSettings.types != UIUserNotificationTypeNone) {
      NSLog(@"didRegisterUser");
      [application registerForRemoteNotifications];
  }
}

Thank you for such a prompt response in advance, I wish I could be clearer on my issue.

Any help is much appreciated.


Solution

  • I am facing same issue. I found some solution during searching as the WWDR intermediate certificate just expired (February 14, 2016). It may cause the issue.

    you can try following steps :

    • In Keychain Access. View -> Show Expired Certificates. Delete expired certificate.
    • Download new WWDR certificate from your developer account.

    Also there are couple of known issue listed by Apple. please refer below link : https://developer.apple.com/support/certificates/expiration/