iOS 远程推送注册的小问题

时间:2023-03-09 04:28:57
iOS 远程推送注册的小问题

iOS8有了新方法,用新方法后,用7.0版本运行会奔溃。只要加一句判断就ok:

#ifdef __IPHONE_8_0
// 在 iOS 8 下注册苹果推送,申请推送权限。 UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge
|UIUserNotificationTypeSound
|UIUserNotificationTypeAlert) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
#else
// 注册苹果推送,申请推送权限。
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound];
#endif