CloudKit share Data between different iCloud accounts but not with everyone

僤鯓⒐⒋嵵緔 提交于 2019-12-02 18:37:32

There are a couple of ways to achieve something like this. In all cases it comes down to:

  • Add a CKReference field that will be populated with the ID of the user that you want to share with.
  • Make sure your predicate will filter for that CKReference field where the ID is yours (shared with you)

Where and how you store that CKReference depends on how you want to share.

  • If you only want to share with only one person, then just include that CKReference field into your main recordType. Do not add it to the message as you stated in your question. Add an extra field.
  • If you want to share to a limited number of people, then you could add a field to your recordType which is a list of CKReference.
  • If you want to share with a large group of people, then you could add a group recordType which would have a groupID plus a groupMembers recordType where you would store all user CKReference id's who are member of that group.

In all cases the solution would be secure. It all comes down to the predicates that you define in your app. If one of your predicate filters is incorrect, then it could happen that someone sees something that is not for him.

In the demo app of EVCloudKitDao is a chat application based on CloudKit. It is using the convenience library EVCloudKitDao but the structure of sharing something would be similar.

CloudKit Sharing was introduced at WWDC 2016. This allows sharing of private database records between a known set of users, which is what it sounds like you're looking for. ...... There is a great overview in the "What's new in CloudKit" session: https://developer.apple.com/videos/play/wwdc2016/226/

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