[英]registerUserNotificationSettings doesn't display alert
I'm asking the user for permission to use local notifications on iOS 8 like this: 我要求用户允许在iOS 8上使用本地通知,如下所示:
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){
UIUserNotificationType types = UIUserNotificationTypeBadge |
UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *notificationSettings =
[UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
}
And I'm handling like this in my AppDelegate: 我正在AppDelegate中处理以下内容:
-(void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
[[NSNotificationCenter defaultCenter] postNotificationName:@"didRegisterUserNotificationSettings" object:nil];
}
But no alert is shown? 但是没有显示警报吗? It skips right to the delegate callback. 它跳到委托回调。 Why is this? 为什么是这样? I'm doing this in the iOS simulator. 我正在iOS模拟器中执行此操作。
Thanks! 谢谢!
警报仅显示一次,要在模拟器上再次显示,请按iOS Simulator
-> Reset Contents and Settings
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.