Instance Method

requestApplicationPermission:completionHandler:

Requests the specified permission from the user to make the user’s identity discoverable.

Declaration

- (void)requestApplicationPermission:(CKApplicationPermissions)applicationPermission completionHandler:(CKApplicationPermissionBlock)completionHandler;

Parameters

applicationPermission

The requested permission. This requested permission applies to the current container only and will not impact permissions granted for other containers. For a list of possible values, see CKApplicationPermissions.

completionHandler

The block to execute with the results. Your block must be capable of executing on any thread of the app.

Discussion

To implement social features in your app, it is possible to correlate a user record with the user’s actual name, but your app must get permission from the user to do so. Making a user record discoverable to the friends (contacts) of that user involves calling the the requestApplicationPermission:completionHandler: method and asking for the CKApplicationPermissionUserDiscoverability permission. When you call that method, CloudKit asks the user on your behalf whether the user record should be made discoverable. If the user grants the request, that user’s contacts can discover that user’s true identity when running the app. To discover the contacts of the current user, you use the discoverAllContactUserInfosWithCompletionHandler: method or one of several other methods to get the related user information.

The first time you request a permission on any of the user’s devices, the user is prompted to grant or deny the request. Once the user grants or denies a permission, subsequent requests for the same permission (on the same or separate devices), do not prompt the user again.

This method runs asynchronously and delivers the results to the block you provide.

See Also

Requesting and Determining App Permissions

- statusForApplicationPermission:completionHandler:

Checks the status of the specified permission asynchronously.