I want my app to check if it has permissions to use the device contacts or not.

This is the code i'm using:

- (void)isContactsAutherizedWithCompletion:(void(^)(BOOL granted))completion {
    self.addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL);

    ABAddressBookRegisterExternalChangeCallback(self.addressBookRef, MyAddressBookExternalChangeCallback, (__bridge_retained  void *)self);
    if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
        ABAddressBookRequestAccessWithCompletion(self.addressBookRef, ^(bool granted, CFErrorRef error) {
            if (granted) {
                completion(YES);
            } else {
                completion(NO);
            }
        });
    } else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized) {
        completion(YES);
    } else {
        completion(NO);
    }
}

But with this code i'm automatically being asked if I want to give permissions. I don't want to be asked, I just want to know if it's has permissions or not.

Anyone has a solution?

Thanks

Related posts

Recent Viewed