最近在用iOS7调试时发现崩溃,原因出在了推送上。记录下来方便以后用到。
// 宏定义判断是否是iOS8以后
#define iOS8 [[[UIDevice currentDevice]systemVersion]floatValue]>=8.0
if(iOS8) {
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
} else{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}