iOS ContactsUI Framework Permissions

2.8k Views Asked by At

I'm fetching contacts using CNContactPickerViewController, and it seems that iOS doesn't automatically ask me for access permissions.

Do I really need permissions for using CNContactPickerViewController or do I need to request for permissions manually?

If I need permissions for this, will my app get rejected if I submit this app to the App Store and if I did not ask for Contacts permissions?

Note: There is nothing stated in the ContactsUI Framework documentation.

4

There are 4 best solutions below

0
On BEST ANSWER

I guess that using ContactsUI API doesn't need permissions since it states in Contacts Framework Reference that permissions will only show (the first time only) on calls to CNContactStore.

Users can grant or deny access to contact data on a per-application basis. Any call to CNContactStore will block the application while the user is being asked to grant or deny access. Note that the user is prompted only the first time access is requested; any subsequent CNContactStore calls use the existing permissions.

Source:

Apple's Contacts Framework Reference

4
On

Check this Apple example. In short, you need to check (switch-case) for ABAddressBookGetAuthorizationStatus(), and if value is kABAuthorizationStatusAuthorized the user has granted access to their contacts. If authorization status is kABAuthorizationStatusNotDetermined, you can even request address book access using method [CNContactStore requestAccessForEntityType:completionHandler:].

0
On

When using Contacts & ContactsUI frameworks, you need to check authorization status with this method: CNContactStore.authorizationStatusForEntityType(). And then you check for enum value CNAuthorizationStatus, you want .Authorized.

If status is .Denied or .NotDetermined you can request access to contacts with method requestAccessForEntityType(), see CNContactStore class for info.

0
On

Permission is not required when using CNContactPickerViewController.

The documentation for CNContactPickerViewController states:

The app using contact picker view does not need access to the user’s contacts and the user will not be prompted for “grant permission” access. The app has access only to the user’s final selection.