CNContactStore.RequestAccesss
-----------------------------

Request access to the user's contacts.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Contacts](component_Contacts.md) | [8.4](newinversion84.md) | ✅ Yes | ❌ No | ❌ No | ❌ No | ✅ Yes |

MBS( "CNContactStore.RequestAccesss" { ; Wait } ) 

**MBS**( **"CNContactStore.RequestAccesss";** /\* Request access to the user's contacts. \*/  
**$Wait**) /\* Optional; Pass 1 to wait for user to decide or 0 to return immediately.  
Default is 0.e.g. 1 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Wait | Pass 1 to wait for user to decide or 0 to return immediately.   Default is 0. | 1 | Optional      Added in version **10.1**. |

### Result

Returns OK or error.

### Description

Request access to the user's contacts.  
Users are able to grant or deny access to contact data on a per-application basis. To request access to contact data, call CNContactStore.RequestAccesss function. This will not block the application while the user is being asked to grant or deny access. The user will only be prompted the first time access is requested; any subsequent ContactStore calls will use the existing permissions.   
  
Later you can use [CNContactStore.AuthorizationStatus](CNContactStoreAuthorizationStatus.md) to check status or [CNContactStore.AuthorizationError](CNContactStoreAuthorizationError.md) to learn why you didn't get permissions.  
  
The application needs to be code signed with entitlements with com.apple.security.personal-information.addressbook identifier. See also my idea here:  
<https://community.filemaker.com/ideas/3240>  
### Examples

Request access:

 Set Variable \[$r ; Value: MBS ( "CNContactStore.RequestAccesss" ) \]  
Request authorization with some error checking:

 Set Variable \[ $r ; Value: MBS ( "CNContactStore.RequestAccesss" ) \]   
Pause/Resume Script \[ Duration (seconds): 1 \]   
Set Variable \[ $r ; Value: MBS ( "[CNContactStore.AuthorizationError](CNContactStoreAuthorizationError.md)" ) \]   
If \[ Length($r ) &gt; 0 \]   
 Show Custom Dialog \[ "Error" ; $r \]   
End If  
Set Variable \[ $groups ; Value: MBS ( "[CNContactStore.Groups](CNContactStoreGroups.md)" ) \]   
If \[ Length ( $groups ) = 0 \]   
 Show Custom Dialog \[ "Possible Problem" ; "Either you have no groups or you did not code sign the app?" \]   
End If  
### See also

- [CNContactStore.AuthorizationError](CNContactStoreAuthorizationError.md)
- [CNContactStore.AuthorizationStatus](CNContactStoreAuthorizationStatus.md)
- [CNContactStore.Groups](CNContactStoreGroups.md)

### Release notes

- **Version 10.1**
    - Added wait parameter for [CNContactStore.RequestAccesss](https://www.mbsplugins.eu/CNContactStoreRequestAccesss.shtml) function.

### Example Databases

- [Mac and iOS/Contacts/Contacts Dialogs](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/Contacts/Contacts%20Dialogs.shtml#2ScriptAnchor_)
- [Mac and iOS/Contacts/Contacts to FileMaker](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/Contacts/Contacts%20to%20FileMaker.shtml#3ScriptAnchor_)
- [Mac and iOS/Contacts/Contacts](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/Contacts/Contacts.shtml#2ScriptAnchor_)
- [Mac and iOS/Contacts/ContactsChanged](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/Contacts/ContactsChanged.shtml#4ScriptAnchor_)

### Blog Entries

- [macOS Privacy and FileMaker](https://www.mbsplugins.de/archive/2020-08-11/macOS_Privacy_and_FileMaker/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.1pr5](https://www.mbsplugins.de/archive/2020-02-24/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 1st August 2018 , last changed 16th February 2020

  
[CNContactStore.RenameGroup](CNContactStoreRenameGroup.md) - [CNContactStore.SetChangeScript](CNContactStoreSetChangeScript.md)

[HTML Version](CNContactStoreRequestAccesss.shtml)