Soon after, the iphone 6/6 Plus will be springing up all over the country. iOS 8 is already a step ahead, but some developers have noticed a change in how the push notifications are registered on iOS 8, with the following error message:
| 1 |
registerForRemoteNotificationTypes: is not supported iniOS 8.0 and later. |
After a successful registration with a new solution, a foreign developer found that the iphone 6 still does not work. Given that the iphone 6/6 Plus will be sold domestically, we can take a proactive look ahead.
IOS 8 has changed the way push messages are registered, so there are some changes that need to be made when developing applications that have push requirements. You can then try adding the following piece of code to the Didfinishlaunchingwithoptions method of the APPDELEGATE.M file to avoid problems with the iphone 6/6 Plus:
| 123456789101112 |
#ifdef __IPHONE_8_0 //这里主要是针对iOS 8.0,相应的8.1,8.2等版本各程序员可自行发挥,如果苹果以后推出更高版本还不会使用这个注册方式就不得而知了……if([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) { UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert categories:nil]; [[UIApplication sharedApplication] registerUserNotificationSettings:settings];} else{ UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound; [[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];}#elseUIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;[[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];#endif |
Then add this method to the APPDELEGATE.M:
| 123456 |
#ifdef __IPHONE_8_0- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings{ [application registerForRemoteNotifications];}#endif |
IOS8 the issue of the change in the way of push registration