前几天运行老版本的代码时,突然报错Attempting to badge the application icon but haven't received permission from the user to badge the application
因为在iOS 8.0之后,设置应用的application badge value需要得到用户的许可,即 用户可以决定是否接收消息通知。。
解决办法:
if ([[UIDevice currentDevice].systemVersion floatValue] >=8.0){
UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
}