Sign in anonymously with iCloud Apple ID

Accordingly, CloudKit Review :

CloudKit also allows your users to anonymously log into your applications using their Apple iCloud IDs without sharing personal data.

I can not find anything else in my documentation about this feature. I already have an application with my own backend, so I don’t need any of the back-end-as-a-service features offered by CloudKit, but I would like to take the opportunity to log in using iCloud account, almost the same as we now doing with facebook and twitter.

Is this possible with CloudKit, or do you also need to use your BAAS features to take advantage of the login experience?

+6
source share
2 answers

From what they discussed at WWDC, you will do this using the fetchUserRecordIDWithCompletionHandler: method on CKContainer . This returns a CKRecordID that matches the current user. This identifier will be stable on all devices, but differently for each application. Therefore, if the same user uses your application on multiple devices, your application will get the same result everywhere, but other applications will get different results from yours.

Once you have CKRecordID , you can find limited other user data (their name and email address, I think) using fetchRecordWithID:completionHandler: This request will trigger a warning to the user, so you will only receive it if he allows it.

This does not require you to use anything else in CloudKit. This requires the user to actually have an iCloud account configured on the device.

+7
source

A permission warning appears only when called -[CKContainer requestApplicationPermission:CKApplicationPermissionUserDiscoverability...] .

If the user grants permission ( CKApplicationPermissionStatusGranted ), you can get the username and last name by running CKDiscoverUserInfosOperation .

A discovery request means that you can see the username and last name and that any other container user can find their user record identifier through an email address or see their first and last name using the user record identifier.

+1
source

Source: https://habr.com/ru/post/971434/


All Articles