Reputation: 4319
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.
Upvotes: 5
Views: 2929
Reputation: 8664
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.
Upvotes: 13
Reputation: 515
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.
Upvotes: 0
Reputation: 515
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:]
.
Upvotes: -1
Reputation: 4319
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 subsequentCNContactStore
calls use the existing permissions.
Source:
Apple's Contacts Framework Reference
Upvotes: 1