IOS 10持续许可警报

时间:2016-11-08 06:35:56

标签: ios objective-c alert

我在应用程序启动时询问位置,联系人和推送通知权限。这三个警报会一个接一个地出现,然后用户才能选择它。此问题仅在ios 10中出现。

以下版本工作正常。

在appDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

[CurrentLocation start]; // Location permission

// Push Notification permission
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerForRemoteNotifications)])
{

UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
    UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];

    [[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
 }


// contacts permission

ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL);

if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
    ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error) {
        if (granted)
        {

        }
    });
}
}

0 个答案:

没有答案