CloudKit Share Use Case

I currently conduct some tests with cloudkit. The (new) photo app in iOS and Mac OS uses CloudKit according Apple.


I would be interresting how the share photo feature is implemented. In photos it is possible to restict access to the photos.

In cloudkit there is only a public and a private database. To share the photos, the only way is to put it in the public database but how is here privacy guaranteed?

I didn't see yet the possiblity to restrict access to specific users on CloudKit level, did i miss something?


I would appreciate any comment on how to implement this typical usecase on cloudkit.


Sharing data only with specific people seems from my perspecitive a typical usecase.


Greetings


Stephan

For accessing the public data you need a signed app or a token for if you are using the api or js. This means that as a developer you have full control over the data. You just have to implement a secure sharing mechanism yourself. Users are loged in using their apple id. You can identify users by that. If you want to share with someone, then add some mechanism where you register that the file/record may be read by the other user.


If you want a demo of how this could work, then have a look at the demo of https://github.com/evermeer/EVCloudKitDao It implements a private chat with other users that also have the app instaled and that are in your adress book. You will also be able to share photo's

I know it has been a year since the question was posted, however, I still think it is a valid question nowadays.


There is currently (as of iOS 9 and OS X 10.11) no way to create a shared database with limited access for certain users. You can use public database and encrypt data and manage it further on the app level, however this solution is:

- not secure enough since you are managing it on the app level

- quite painful to maintain due to many reasons, at the end of the day, that would be a public database


Now, regarding Photos app. I don't think it uses CloudKit for shared photostreams. This feature was available there before Photos were re-written for CloudKit and I think that it still uses the old sharing technology for photostreams.

Sharing was introduced at this year's WWDC, allowing you to securely share CloudKit data between users. You can get more details at:

https://developer.apple.com/videos/play/wwdc2016/226/


Some direct links to relevant documentation:

https://developer.apple.com/reference/cloudkit/ckrecord/1640378-share

https://developer.apple.com/reference/cloudkit/ckshare

Can you restrict Sharing to View only so that Downloads are prevented? I do not see any mention of this in the documentation.

Have a look at the permissions of a CKSharingParticipant - you can alter read/write settings there.

CloudKit Share Use Case
 
 
Q