ios8设置application badge value

在ios8中,直接设置application badge value会出错

 1 [[UIApplication sharedApplication] setApplicationIconBadgeNumber:count]; 

曝出”Attempting to badge the application icon but haven‘t received permission from the user to badge the application“的错误。

  原因是因为在ios8中,设置应用的application badge value需要得到用户的许可。使用如下方法咨询用户是否许可应用设置application badge value

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];

程序运行时,会弹出提示框给用户

ios8设置application badge value

之后再通过

 1 [[UIApplication sharedApplication] setApplicationIconBadgeNumber:count]; 

设置application badge value

 

ios8设置application badge value,布布扣,bubuko.com

ios8设置application badge value

上一篇:最新的WIN10多用户远程方法--RDPWARP软件


下一篇:iOS开发拓展篇—xib中关于拖拽手势的潜在错误