首页 > 代码库 > ios推送兼容ios7,8

ios推送兼容ios7,8

ios推送兼容ios7,8

by 伍雪颖

UIApplication *APPLICATION = [UIApplication sharedApplication];
// ios 8
if ([APPLICATION respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) {
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge|
         UIRemoteNotificationTypeSound|
         UIRemoteNotificationTypeAlert)categories:nil];
    [APPLICATION registerUserNotificationSettings:settings];
    [APPLICATION registerForRemoteNotifications];
} else { // ios7
    [APPLICATION registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge
                                                     |UIRemoteNotificationTypeSound
                                                     |UIRemoteNotificationTypeAlert)];
}


ios推送兼容ios7,8