标签:
原来iOS8增加了启动授权,需要用户同意下才能注册通知。
添加如下代码:
- (void)RegistNotificationSettings
{
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];
}
}
你可以在注册通知之前调用,也可以在app启动时候调用
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
// todo ...
[self RegistNotificationSettings];
return YES;
}
注意:只要用户对app授权过了,以后即使删除再次安装,也默认为授权了。
iOS8 UILocalNotification 增加启动授权
标签:
原文地址:http://www.cnblogs.com/crash-wu/p/4950415.html