Search code examples
ioscloudkit

Can CloudKit user phone numbers be retrieved using `CKDiscoverAllUserIdentitiesOperation`?


Background

I am retrieving all the users for my app using the recommended CloudKit operation, CKDiscoverAllUserIdentitiesOperation.

This operation is designed to returns each user's info in a CKUserIdentity object. The lookupInfo attribute of the user identity has fields that can contain the user's email address and the user's phone number.

e.g.

user.lookupInfo.phoneNumber
user.lookupInfo.emailAddress

Question

When I run this operation, I only ever get each user's email address. The phoneNumber field is never populated.

How do I retrieve these user identities and have them include the user's phone number? (Is this possible?)

Additional Info

I am able to retrieve individual users with their phone numbers using the discoverUserIdentity(withPhoneNumber... CloudKit function, so I know that these accounts are linked to phone numbers.


Solution

  • All you get is the email. That's it. It's not possible to get any more info than that using CKDiscoverAllUserIdentitiesOperation. And that is only for users that have agreed to be looked up via email while using your app.

    The only time the phone number is filled in is if you specifically lookup the user by phone number. Of course that's kind of pointless since you already know the phone number.