registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; [[UIApplication sharedApplication] registerForRemoteNotifications]; } else { //这里还是原来的代码 [[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)]; }
判断PUSH是否打开
{ UIRemoteNotificationType types; if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { types = [[UIApplication sharedApplication] currentUserNotificationSettings].types; } else { types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; } return (types & UIRemoteNotificationTypeAlert); }
时间: 2024-08-29 10:55:53