iOS ContactsUI Framework Permissions
Asked Answered
G

4

5

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.

Githens answered 22/4, 2016 at 7:53 Comment(0)
G
1

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

Githens answered 22/4, 2016 at 7:59 Comment(0)
O
13

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.

Oblige answered 12/9, 2016 at 14:8 Comment(0)
G
1

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

Githens answered 22/4, 2016 at 7:59 Comment(0)
C
0

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.

Caracalla answered 22/4, 2016 at 8:17 Comment(0)
C
-1

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:].

Caracalla answered 22/4, 2016 at 8:0 Comment(4)
Thanks! But I'm using Contacts and ContactsUI frameworks since AddressBook framework is already deprecated. And I don't think they have a similar API.Githens
Sorry, I always used this code so I did not read carefully.. In short, when using Contact & ContactUI frameworks, you need to check authorization status with this method: CNContactStore.authorizationStatusForEntityType(). And then you check for enum value CNAuthorizationStatus, you want .Authorized.Caracalla
No worries. I just found a statement in Apple docs which may indicate that ContactsUI Framework does not need permission: https://mcmap.net/q/1899326/-ios-contactsui-framework-permissionsGithens
Regardless, you should always check if app has the required permission to access contacts, because user can change the authorization state of the app through the device Settings.app.Caracalla

© 2022 - 2024 — McMap. All rights reserved.