didRegisterForRemoteNotificationsWithDeviceToken not called in ios8, but didRegister...Settings is

I followed this thread, but the method didRegisterForRemoteNotificationsWithDeviceToken is still not called :

the documentation says :

After you call the registerForRemoteNotifications method of the UIApplication object, the app calls this method when device registration completes successfully

didRegisterUser appears well, but not did register notif.

Here is my code in the AppDelegate (the app version is 8.1) :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    //register notif
    UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
                                                    UIUserNotificationTypeBadge |
                                                    UIUserNotificationTypeSound);
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes categories:nil];
    [application registerUserNotificationSettings:settings];


    return YES;
}

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
    //register to receive notifications
    [application registerForRemoteNotifications];
    NSLog(@"didRegisterUser");
}

-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
    NSLog(@"error here : %@", error);//not called
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    /*
    // Store the deviceToken in the current installation and save it to Parse.
    PFInstallation *currentInstallation = [PFInstallation currentInstallation];
    [currentInstallation setDeviceTokenFromData:deviceToken];
    currentInstallation.channels = @[ @"global" ];
    [currentInstallation saveInBackground];
     */
    NSLog(@"did register notif");//not called
}

I also have background mode -> remote notification in the info.plist.


After a long dig I found that on 19 July, 2016 due to some error or updation at Apple's end , the didRegisterForRemoteNotificationsWithDeviceToken method would not be called even if every condition like Internet connection , Device and the methods used are perfect.

Refer to this link for confirmation https://forums.developer.apple.com/thread/52224

To verify please have a look in your other apps too. I had wasted my several hours but hope it helps someone. Thanks.


For 19 July 2016:-

As per Apple Developer form, there is an issue regarding Sandbox APNS down. so there may be issue from apple side,thats why delegates like application:didRegisterForRemoteNotificationsWithDeviceToken: and application:didFailToRegisterForRemoteNotificationsWithError: is not called.

To check the current status of APNS Sandbox this link... By now according to status APNS Sandbox is working fine and it's normal. so maybe there is some other bug from the apple side

So just don't worry if your methods are perfect and certificates are valid. This is just an issue from the Apple side and as soon as the issue resolved, your methods work perfectly(if everything is fine from your side).

Note that Production is working fine and the issue is regarding Sandbox APNS.


I had this issue and finally found the note in Apple Developer web site and solved this issue:

Registering, Scheduling, and Handling User Notifications

iOS Note in the section: "Registering for Remote Notifications:

iOS Note: If a cellular or Wi-Fi connection is not available, neither the application:didRegisterForRemoteNotificationsWithDeviceToken: method nor the application:didFailToRegisterForRemoteNotificationsWithError: method is called. For Wi-Fi connections, this sometimes occurs when the device cannot connect with APNs over port 5223. If this happens, the user can move to another Wi-Fi network that isn’t blocking this port or, on an iPhone or iPad, wait until the cellular data service becomes available. In either case, the device should be able to make the connection, and then one of the delegation methods is called.

My iPhone only connected with Wifi, reboot iPhone and reconnect to WiFi AP solved this issue.