当我在iOS 10上启动我的应用程序时,我得到请求通知权限两次。 第一个短暂出现并立即消失而不允许我做任何动作,然后我得到第二个弹出窗口,其正常行为等待“允许”或“拒绝”来自用户。iOS 10请求通知权限触发两次
这是我的代码,在iOS 10之前运行良好。
在该方法中didFinishLaunchingWithOptions从的AppDelegate:
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
#ifdef __IPHONE_8_0
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge
|UIRemoteNotificationTypeSound
|UIRemoteNotificationTypeAlert) categories:nil];
[application registerUserNotificationSettings:settings];
#endif
} else {
UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[application registerForRemoteNotificationTypes:myTypes];
}
我应该执行,以解决这一双重要求允许一些适用于iOS 10?
见这是在迅速:https://iosdevcenters.blogspot.com/2016/09/usernotifications-framework-push.html –