I had a problem after updating our application for working with iOS 8, where registerForRemoteNotificationTypes does not seem to work on the phone with iOS 7, because didRegisterForRemoteNotificationsWithDeviceToken is not called and the "Allow Push Notifications" dialog box does not appear on the application. This is the code I'm using.
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
NSLog(@"iOS 8 Registering for remote notification");
UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
} else {
NSLog(@"Registering for remote notification");
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}
This code is perfect for phones running iOS 8, and not iOS 7. Another bit of information we managed to get push notifications for working on an iOS 7 phone only after launching the application through xcode with a connected phone. Then we deployed the same code as ad Hoc on another iPhone and iPad running iOS 7, and none of them worked. Is there something obvious I'm missing here.