微博项目做完了,但是中间遇到了一个问题,就是应用程序图标上不能显示提醒数字,而且会报错:
Attempting to badge the application icon but haven't received permission ...
如下图:
原因是在Xcode的模拟器上,因为Xcode的默认模拟器是iOS8.1,而在7之前都是能够直接显示的,我查了一些资料,看了看,总结了一下,需要一下代码,而且代码要写在:
AppDelegate.m的
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
方法里
//获取系统版本号
float sysVersion=[[UIDevice currentDevice]systemVersion].floatValue;
if (sysVersion>=8.0) {
UIUserNotificationType type=UIUserNotificationTypeBadge | UIUserNotificationTypeAlert | UIUserNotificationTypeSound;
UIUserNotificationSettings *setting=[UIUserNotificationSettings settingsForTypes:type categories:nil];
[[UIApplication sharedApplication]registerUserNotificationSettings:setting];
}
return YES;