How to Share a CloudKit Record with Multiple Participants While Keeping Individual Records Private?

In a CloudKit private database, the Owner creates a custom zone and performs the following actions:

  1. Creates CKRecord1 with CKShare1 and invites Participant1 to it.
  2. Creates CKRecord2 with CKShare2 and invites Participant2 to it.
  3. Creates CKRecordShared, which should be accessible to both Participant1 and Participant2.

How can I achieve step 3?

I observed that:

  • Setting a regular reference from CKRecord1 (or CKRecord2) to CKRecordShared does not automatically make CKRecordShared accessible to Participant1 (or Participant2).
  • CKRecordShared can only have one parent, so it cannot be directly linked via parent reference to both Participant1 and Participant2 at the same time.

One potential solution I see is to have the Owner create a separate CKShare for CKRecordShared and share it explicitly with each participant. However, this approach could lead to user errors, as it requires careful management of multiple shares for each participant.

Is there a better way to handle this scenario, ensuring that CKRecordShared is accessible to multiple participants without introducing unnecessary complexity or potential errors?

Answered by DTS Engineer in 821520022

I observed that: Setting a regular reference from CKRecord1 (or CKRecord2) to CKRecordShared does not automatically make CKRecordShared accessible to Participant1 (or Participant2).

CKRecordShared can only have one parent, so it cannot be directly linked via parent reference to both Participant1 and Participant2 at the same time.

Yeah, the above behavior is as-designed.

One potential solution I see is to have the Owner create a separate CKShare for CKRecordShared and share it explicitly with each participant.

Yeah, this should work, assuming that CKRecordShared is not a child or parent of CKRecord1 or CKRecord2.

However, this approach could lead to user errors, as it requires careful management of multiple shares for each participant.

It is perfectly possible that a participant partipates multiple shares. That may add more complexity, but you app can implement appropriate UI for a participant (or owner) to manage the shared records.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

I observed that: Setting a regular reference from CKRecord1 (or CKRecord2) to CKRecordShared does not automatically make CKRecordShared accessible to Participant1 (or Participant2).

CKRecordShared can only have one parent, so it cannot be directly linked via parent reference to both Participant1 and Participant2 at the same time.

Yeah, the above behavior is as-designed.

One potential solution I see is to have the Owner create a separate CKShare for CKRecordShared and share it explicitly with each participant.

Yeah, this should work, assuming that CKRecordShared is not a child or parent of CKRecord1 or CKRecord2.

However, this approach could lead to user errors, as it requires careful management of multiple shares for each participant.

It is perfectly possible that a participant partipates multiple shares. That may add more complexity, but you app can implement appropriate UI for a participant (or owner) to manage the shared records.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

How would one go about implementing sharing model where with one User action two zones are shared and two zones are accepted?

I am not sure if I understand the question correctly. If you can elaborate with a concrete use case, I'd try to comment. It seems that the topic is shifting to zone sharing, which is quite different from hierarchical sharing. See What's new in CloudKit (from 22:45) for more information. To share two zones, a owner needs to create one CKShare for each zone and go through the sharing process one by one; a participant needs to accept one by one as well.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

How to Share a CloudKit Record with Multiple Participants While Keeping Individual Records Private?
 
 
Q