registerUserNotificationSettings 不显示警报
registerUserNotificationSettings doesn't display alert
我请求用户允许在 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 模拟器中执行此操作。
谢谢!
警报只显示一次,要在模拟器上再次显示它应该按 iOS Simulator
-> Reset Contents and Settings
我请求用户允许在 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 模拟器中执行此操作。
谢谢!
警报只显示一次,要在模拟器上再次显示它应该按 iOS Simulator
-> Reset Contents and Settings