今天刚升级到ios8系统,原项目编译发现异常信息:
registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.
于是查了资料,原来是注册方式改变了,蛋疼的苹果!解决方法如下,同时对ios8以下版本进行处理:
if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) { // iOS 8 推送注册 [application registerUserNotificationSettings: [UIUserNotificationSettingssettingsForTypes: (UIUserNotificationTypeSound |UIUserNotificationTypeAlert |UIUserNotificationTypeBadge) categories:nil]]; [application registerForRemoteNotifications]; } else { // iOS 8 以下版本推送注册 [application registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeAlert |UIRemoteNotificationTypeSound)]; }