简体   繁体   English

我如何使用 Cloudkit 快速从 iCloud 获取当前用户信息

[英]How do i get the current user information from iCloud using Cloudkit , swift

My question is how do i get the currently logged in user information from iCloud using cloudkit.我的问题是如何使用 cloudkit 从 iCloud 获取当前登录的用户信息。 i want to add more fields to this user defaults section and retrieve those data when i want it.我想向此用户默认部分添加更多字段,并在需要时检索这些数据。 I have tried making new schema to save user data.我尝试制作新模式来保存用户数据。

It is possible to add extra fields to the User recordType in CloudKit, but it's not adviced.可以在 CloudKit 中向 User recordType 添加额外字段,但不建议这样做。 The User recordType is a special recordType with lots of limitations.用户记录类型是一种特殊的记录类型,有很多限制。 It's better to create a new record type where you save additional user settings.最好创建一个新的记录类型来保存其他用户设置。 Then you could set a CKReference to the actual user recordId.然后,您可以将 CKReference 设置为实际的用户记录 ID。

For getting the active user recordID use the CKcontainer function fetchUserRecordIDWithCompletionHandler .要获取活动用户记录CKcontainer使用CKcontainer函数fetchUserRecordIDWithCompletionHandler If you want to get the first and last name (you can't get more information) then use the function discoverUserInfoWithUserRecordID如果您想获取名字和姓氏(您无法获得更多信息),请使用功能discoverUserInfoWithUserRecordID

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM