0
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
    ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error) {
        if (granted) {
            // First time access has been granted, add the contact
            [self prepareContactsIDs];
        } else {
            UIAlertView *accessDenied = [[UIAlertView alloc] initWithTitle:@"Need Access to Addressbook" message:@"KeepItClean requires an access to addressbook in order to be usable" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
            [accessDenied show];
        }
    });
}
else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized) {
    // The user has previously given access, add the contact
    if ([self isFirstRun]) {
        [self prepareContactsIDs];
    }
}
else {
    // The user has previously denied access
    // Send an alert telling user to change privacy setting in settings app
    UIAlertView *accessDenied = [[UIAlertView alloc] initWithTitle:@"Need Access to Addressbook" message:@"KeepItClean requires an access to addressbook in order to be usable" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    [accessDenied show];
}

There is something i don't understand here, when the user is prompted to give access, if he taps cancel, i don't get my 2nd UIAlertView showing up, the (accessDenied) alert view.

Also i feel there is something i don't understand that is related to dispatching and queues.

Gabriel.Massana
  • 8,165
  • 6
  • 62
  • 81
Moody
  • 352
  • 3
  • 15

1 Answers1

0

Try this

ABPeoplePickerNavigationController *peoplePicker = [[ABPeoplePickerNavigationController  alloc] init];
peoplePicker.peoplePickerDelegate= self;
ABAddressBookRef UsersAddressBook = ABAddressBookCreateWithOptions(NULL, NULL);

if (ABAddressBookGetAuthorizationStatus()!= kABAuthorizationStatusDenied)
{ 
    //Show alert of access
} 
else
{
    //Show alert of access denied
}
toasted_flakes
  • 2,502
  • 1
  • 23
  • 38
Mohit
  • 516
  • 7
  • 24
  • 1
    Why post a pastie instead of posting the code directly? @toasted_flakes has been kind enough to do this for you this time, but in the future, please post the code in the answer itself. – Qantas 94 Heavy Jul 20 '14 at 11:05
  • Your answer is completely irrelevant to my question.. please check again my question and my code. – Moody Jul 20 '14 at 12:27
  • Anything?! I am still stuck and i don't understand this weird behavior – Moody Jul 20 '14 at 20:21