I use APNS and it's work fine on iOS 9. With the new push API changes on iOS10 i cant register for push notification so i insert the next changes:
- Enable push notification in the target capabilities tab.
In didFinishLaunchingWithOptions we check the OS version and register as followed :
if (SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(@"10.0")) { //ios 10 Notifiction UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; center.delegate = self; [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){ if( !error ){ [[UIApplication sharedApplication] registerForRemoteNotifications]; NSLog(@"iOS 10 push notification register successfully "); } }]; } else { // iOS 8-9 Notifications [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; [[UIApplication sharedApplication] registerForRemoteNotifications]; NSLog(@"iOS 9 push notification register successfully "); }
With this changes I manage to perform registration in iOS 9 and iOS 10 but I have couple of problems :
- Once I enable the push notification in the target capabilities tab the push notification stop working on iOS 9 although the registration was complete successfully .
- The push doesn’t work on iOS 10 at all although the registration was complete successfully .
Please keep in mind that if I turn off the push notification in the target capabilities tab (with the same code) the push return to work on iOS 9 but I cant register for APNS on iOS 10.