2

我正在使用以下代码向地址簿询问权限并将其保存到应用程序的 UserDefaults。

if (ABAddressBookRequestAccessWithCompletion != NULL)
{
    // we're on iOS 6
    ABAddressBookRef addressBookRef = ABAddressBookCreate();
    ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error) {
        accessgranted = granted;
        if(accessgranted)
        {
             [self saveaddressbookpermission:accessgranted];
            [NSThread detachNewThreadSelector:@selector(startbgprocess) toTarget:self withObject:nil];
        }
    });
    CFRelease(addressBookRef);

}
else {
    // we're on iOS 5 or older
    accessgranted = YES;
    [self saveaddressbookpermission:accessgranted];
    NSLog(@"in iOS 5");
   [NSThread detachNewThreadSelector:@selector(startbgprocess) toTarget:self withObject:nil];

}

问题是当我尝试使用Setting->General->Reset -> Reset Location & privacy 重置隐私设置时,但如果我尝试从 Settings->Privacy-> 更改隐私设置并从那里关闭权限我的应用程序崩溃。我该如何处理这种情况。请让我知道是否需要任何其他信息,因为我无法找到有关此的任何信息。

4

0 回答 0