Anonymously Log In to an App with iCloud Apple ID

萝らか妹 提交于 2019-12-03 14:15:10

问题


According to this CloudKit overview:

CloudKit also enables your users to anonymously sign in to your apps with their iCloud Apple IDs without sharing their personal information.

I can't find anything else in their documentation about this capability. I already have an app with my own backend, so I wouldn't need any of the back-end-as-a-service features that CloudKit offers, but I would like to take advantage of logging a user in with their iCloud account, much the same way we currently do with Facebook and Twitter.

Is that possible with CloudKit, or do you also have to leverage their BAAS features in order to take advantage of login?


回答1:


From what they discussed at WWDC, you'd do this using the fetchUserRecordIDWithCompletionHandler: method on CKContainer. That returns a CKRecordID that corresponds to the current user. This ID will be stable across devices but different for each app-- so if the same person uses your app on multiple devices, your app will get the same result everywhere, but other apps would get different results from yours.

Once you have the CKRecordID you can look up limited other user data (their name and email, I think) using fetchRecordWithID:completionHandler:. This request will trigger a permission alert to the user, so you only get it if they allow it.

This doesn't require you to use anything else in CloudKit. It does require that the user actually have an iCloud account configured on the device.




回答2:


The permission alert will only pop if you call -[CKContainer requestApplicationPermission:CKApplicationPermissionUserDiscoverability...].

If the user grants permission (CKApplicationPermissionStatusGranted) then you can get the user's first and last name by running a CKDiscoverUserInfosOperation.

Requesting discoverability means that you can see the user's first and last name, and that any other user of the container can find their user record ID via an email address or look up their first and last name via a user record ID.



来源:https://stackoverflow.com/questions/24458498/anonymously-log-in-to-an-app-with-icloud-apple-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!