當我在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 –