Push notification 在iOS 10中,UNUserNotificationCenter';用户的授权状态错误

Push notification 在iOS 10中,UNUserNotificationCenter';用户的授权状态错误,push-notification,ios10,unusernotificationcenter,Push Notification,Ios10,Unusernotificationcenter,在AppDelegate的didFinishLaunchingWithOptions中,我实现了获取授权状态的代码 UNAuthorizationOptions authOptions = (UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound); [[UNUserNotificationCenter currentNotificationCenter] requestAuthor

在AppDelegate的didFinishLaunchingWithOptions中,我实现了获取授权状态的代码

UNAuthorizationOptions authOptions = (UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound);
[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) {
    if (granted) {
        [application registerForRemoteNotifications];
    }
}];
但是,UNUserNotificationCenter.currentNotificationCenter()。下一次当我打开我的应用程序时,它会返回正确的授权状态。
如何修复它?

您是否找到了解决方案?是的。我发现了。我已经调用了RegisterForeMoteNotification方法两次。移除一个后,问题就解决了