Contents

fetchUserRecordID(completionHandler:)

Fetches the user record ID of the current user.

Declaration

func fetchUserRecordID(completionHandler: @escaping  @Sendable (CKRecord.ID?, (any Error)?) -> Void)
func userRecordID() async throws -> CKRecord.ID

Parameters

  • completionHandler:

    The handler to execute with the fetch results.

Discussion

The closure doesn’t return a value and takes the following parameters:

  • The user record ID, or nil if the user disables iCloud or the device doesn’t have an iCloud account.

  • An error if a problem occurs, or nil if CloudKit successfully retrieves the user record ID.

CloudKit returns a CKError.Code.notAuthenticated error when any of the following conditions are met:

  • The device has an iCloud account but the user disables iCloud.

  • The device has an iCloud account with restricted access.

  • The device doesn’t have an iCloud account.

See Also

Discovering User Records