Can't Access Contacts Sources on Device in iOS 6

后端 未结 3 1145
遥遥无期
遥遥无期 2021-02-13 10:39

This code worked OK on iOS 5.1 and also does work in the iPhone simulator with iOS 6. It fails silently on my iPhone 4 running iOS 6. The end result is that I cannot add a per

3条回答
  •  清酒与你
    2021-02-13 10:50

    I had the same issue and I could not get the Allow Access To Contacts alert to popup.

    The Answer was posted by Kyle here: https://stackoverflow.com/a/12648938/480415

      // Request authorization to Address Book
      ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL);
    
      if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
        ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error) {
              // First time access has been granted, add the contact
        });
      }
      else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized) {
            // The user has previously given access, add the contact
      }
      else {
            // The user has previously denied access
            // Send an alert telling user to change privacy setting in settings app
      }
    

提交回复
热议问题