---
title: "discoverUserIdentity(withPhoneNumber:completionHandler:)"
framework: cloudkit
role: symbol
role_heading: Instance Method
path: "cloudkit/ckcontainer/discoveruseridentity(withphonenumber:completionhandler:)"
---

# discoverUserIdentity(withPhoneNumber:completionHandler:)

Fetches the user identity for the specified phone number.

## Declaration

```swift
func discoverUserIdentity(withPhoneNumber phoneNumber: String, completionHandler: @escaping @Sendable (CKUserIdentity?, (any Error)?) -> Void)
```

## Parameters

- `phoneNumber`: The user’s phone number.
- `completionHandler`: The handler to execute with the fetch results.

## Discussion

Discussion This closure doesn’t return a value and takes the following parameters: The user identity for the phone number, or nil if CloudKit can’t find an identity. An error if a problem occurs, or nil if CloudKit successfully fetches a user identity. Use this method to retrieve the identity of a user who the current user knows. The user you’re searching for must meet the following criteria: The user has run the app. The user grants the userDiscoverability permission for the container. This method searches for the user asynchronously and with a low priority. If you want the task to execute the request with a higher priority, create an instance of CKDiscoverUserIdentitiesOperation and configure it to use the necessary priority.

## See Also

### Discovering User Records

- [discoverAllIdentities(completionHandler:)](cloudkit/ckcontainer/discoverallidentities(completionhandler:).md)
- [discoverUserIdentity(withEmailAddress:completionHandler:)](cloudkit/ckcontainer/discoveruseridentity(withemailaddress:completionhandler:).md)
- [discoverUserIdentity(withUserRecordID:completionHandler:)](cloudkit/ckcontainer/discoveruseridentity(withuserrecordid:completionhandler:).md)
- [fetchShareParticipant(withEmailAddress:completionHandler:)](cloudkit/ckcontainer/fetchshareparticipant(withemailaddress:completionhandler:).md)
- [fetchShareParticipant(withPhoneNumber:completionHandler:)](cloudkit/ckcontainer/fetchshareparticipant(withphonenumber:completionhandler:).md)
- [fetchShareParticipant(withUserRecordID:completionHandler:)](cloudkit/ckcontainer/fetchshareparticipant(withuserrecordid:completionhandler:).md)
- [fetchUserRecordID(completionHandler:)](cloudkit/ckcontainer/fetchuserrecordid(completionhandler:).md)
- [CKCurrentUserDefaultName](cloudkit/ckcurrentuserdefaultname.md)
- [CKOwnerDefaultName](cloudkit/ckownerdefaultname.md)
