Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

CNContactStore.RequestAccesss

Request access to the user's contacts.

Component Version macOS Windows Linux Server iOS SDK
Contacts 8.4 ✅ Yes ❌ No ❌ No ❌ No ✅ Yes
MBS( "CNContactStore.RequestAccesss" { ; Wait } )   More

Parameters

Parameter Description Example Flags
Wait Available in MBS FileMaker Plugin 10.1 or newer.
Pass 1 to wait for user to decide or 0 to return immediately.
Default is 0.
1 Optional

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 to check status or CNContactStore.AuthorizationError 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" ) ]
If [ Length($r) > 0 ]
    Show Custom Dialog [ "Error" ; $r ]
End If
Set Variable [ $groups ; Value: MBS( "CNContactStore.Groups" ) ]
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

Release notes

Example Databases

Blog Entries

This function checks for a license.

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


CNContactStore.RenameGroup - CNContactStore.SetChangeScript