我要求用户允许在iOS 8上使用本地通知,如下所示:
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){
UIUserNotificationType types = UIUserNotificationTypeBadge |
UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *notificationSettings =
[UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
}
我在AppDelegate中这样处理:
-(void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
[[NSNotificationCenter defaultCenter] postNotificationName:@"didRegisterUserNotificationSettings" object:nil];
}
但是没有显示警报?它会直接跳到委托回调。为什么是这样?我在iOS模拟器中这样做。
谢谢!
答案 0 :(得分:1)
仅显示一次警报,要在模拟器上再次显示,请按iOS Simulator
- > Reset Contents and Settings