0

I need to Turn Off contacts access from myApp when user off(Disable) using toggle. As well get Authority of contacts when toggle will On(Enable).

Have any one idea how to fix.

Ayaz Rafai
  • 15
  • 5

1 Answers1

0

Very first I want to let you know that Apple does not allow to modify Privacy Settings with any of Apple authorized way ,programmatically........So if you want to handle this issue you can check for the permission that if it is granted or not .....Then you can handle your events a/c to that....This method will fire an alert from native OS,asking for access....

//Ask user to grant the permission to access contacts
- (void)requestPermissionForContactsAccessAndFetchWithCompletion
{
    ABAuthorizationStatus status = ABAddressBookGetAuthorizationStatus();

    if (status != kABAuthorizationStatusAuthorized && status != kABAuthorizationStatusNotDetermined) {
        // tell user to enable contacts in privacy settings
        NSLog(@"You previously denied access: You must enable access to contacts in settings");
    }

    CFErrorRef error = NULL;
    ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, &error);
    if (error)
    {
        if (addressBook) CFRelease(addressBook);

    }
    ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {

        if (error) {
            NSLog(@"ABAddressBookRequestAccessWithCompletion error: %@", CFBridgingRelease(error));
        }

        if (granted) {
      //Get all contact if access is granted--This will call when access granted
        [self getContactsFromAddressBook:addressBook];

        }else{


        }

    });

}

Let me know if you need more help....

Prasanna
  • 945
  • 10
  • 24