没有注册会报错:
with a badge number but haven't received permission from the user to badge ......
解决方法:在appdelegate.m文件里didFinishLaunchingWithOptions方法添加注册,如下:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
return YES;
}
当尝试设置通知徽章但未获得用户授权时,iOS应用会报错。解决此问题需在AppDelegate.m的didFinishLaunchingWithOptions方法中添加注册用户通知设置的代码,如下所示:设置UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert,并调用registerUserNotificationSettings方法。
2095

被折叠的 条评论
为什么被折叠?



