Whenever the user presses OK
on the AddressBook permission UIAlertView
everything goes fine except for a delay in executing these commands, weirdly it takes about 5 seconds for these commands to be executed, even though the NSLog
is printed instantly.
The same code works instantly in Calendar permission.
Can someone please help me here? thank you.
The code which is being executed after a delay(5 secs)
NSLog(@"Granted!");
_1234.backgroundColor = [UIColor lightGrayColor]; [_12345 setHidden:NO]; [ _qwerty setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal]; [_qwerty1 setHidden:YES];
Complete function
ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL);
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error) {
if (error)
{ // display error message here }
else if (!granted)
{ // display access denied error message here } else { NSLog(@"Granted!"); //this gets printed instantly _qwerty.userInteractionEnabled = NO; _1234.backgroundColor = [UIColor lightGrayColor]; [_12345 setHidden:NO]; [ _qwerty setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal]; [_qwerty1 setHidden:YES]; [self qwerty4]; } }); }