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

 

posted @ 2014-12-30 15:01  6度XZ  阅读(275)  评论(0编辑  收藏  举报