Instance Method

fetchUserRecordID(completionHandler:)

Returns the user record ID associated with the current user.

Declaration

func fetchUserRecordID(completionHandler: @escaping (CKRecord.ID?, Error?) -> Void)

Parameters

completionHandler

The block to execute with the results. Your block must be capable of executing on any thread of the app. This block returns no value and takes the following parameters:

recordID

The ID of the user record for the current user, or nil if the current device is not configured with an iCloud account.

error

An error object if a problem occurs, or nil if the record ID is retrieved successfully.

Discussion

At startup time, fetching the user record ID may take longer while CloudKit makes the initial iCloud account request. After the initial fetch, accessing the user record ID should take less time. If no iCloud account is associated with the device, or if access to the user’s iCloud account is restricted, this method returns an error of type CKError.Code.notAuthenticated.

See Also

Discovering User Records

func discoverAllContactUserInfos(completionHandler: ([CKDiscoveredUserInfo]?, Error?) -> Void)

Retrieves information about all discoverable users that are known to the current user.

Deprecated
func discoverAllIdentities(completionHandler: ([CKUserIdentity]?, Error?) -> Void)

Fetches all user records that match an entry in the user’s address book.

func discoverUserIdentity(withEmailAddress: String, completionHandler: (CKUserIdentity?, Error?) -> Void)

Returns the user record ID associated in the user’s contacts with the email address.

func discoverUserIdentity(withPhoneNumber: String, completionHandler: (CKUserIdentity?, Error?) -> Void)

Returns the user record ID associated in the user’s contacts with the phone number.

func discoverUserIdentity(withUserRecordID: CKRecord.ID, completionHandler: (CKUserIdentity?, Error?) -> Void)

Retrieves information about a single user based on the ID of the corresponding user record.

func discoverUserInfo(withEmailAddress: String, completionHandler: (CKDiscoveredUserInfo?, Error?) -> Void)

Retrieves information about a single user based on that user’s email address.

Deprecated
func discoverUserInfo(withUserRecordID: CKRecord.ID, completionHandler: (CKDiscoveredUserInfo?, Error?) -> Void)

Retrieves information about a single user based on the ID of the corresponding user record.

Deprecated
func fetchShareParticipant(withEmailAddress: String, completionHandler: (CKShare.Participant?, Error?) -> Void)

Retrieves information about a single share participant (a person who accepted a shared record) based on that participant’s email address.

func fetchShareParticipant(withPhoneNumber: String, completionHandler: (CKShare.Participant?, Error?) -> Void)

Retrieves information about a single share participant (a person who accepted a shared record) based on that participant’s phone number.

func fetchShareParticipant(withUserRecordID: CKRecord.ID, completionHandler: (CKShare.Participant?, Error?) -> Void)

Retrieves information about a single share participant based on the ID of the corresponding user record.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software