Deleting/Leaving a share

What is the best-practice for deleting/leaving a share?

I'm trying to figure out how to stop sharing a record you've previously shared, as well as how to leave a share you've previously joined that someone else has shared. Hopefully I've just missed the documentation around this point, but I see little on the topic.

Can someone confirm or correct this approach? Thanks.

Say Alice has a record named record-A.

Alice shares record-A
  1. Alice's privateCloudDatabase now contains a cloudkit.share record.

  2. Alice's record-A.share is set to a reference to that cloudkit.share.

Bob joins the share
  1. Bob's sharedCloudDatabase now contains a cloudkit.share record referencing Alice's cloudkit.share?

Bob wants to leave the share
  1. QUESTION: Is it enough to simply delete Bob's cloudkit.share in his sharedCloudDatabase?

Alice wants to stop sharing
  1. QUESTION: Is it enough to simply delete Alice's cloudkit.share in her privateCloudDatabase?

  2. QUESTION: When Alice stops sharing, is Bob's cloudkit.share automatically deleted from his sharedCloudDatabase?

I should add that I'm trying to understand how this works independently of the sharing controller. I appreciate that the sharing controller offers a "Stop Sharing" button for the owner and a "Remove Me" button for the joined participant. I was wondering about the programmatic approach.

Did you ever figure this out? I want to know how to delete a share programmatically in iOS using Xcode with Swift. I need to use it as a programmer, not for the iOS app to allow the user to delete a share. I don't believe there is any other way to delete a share than with code. It doesn't look like CloudKit Dashboard allows me to delete all records in a database. The dashboard does not allow querying cloudkit.share.

I found the following at Developer->Documentation->CloudKit->Shared Records. This must be Apple's prescribed method.

To stop sharing, the share’s owner must delete the share or, for shared hierarchies, the root record. If a participant wants to leave the share, delete the share record from their shared database. Use UICloudSharingController or NSSharingService to allow a participant to stop participating. Or remove them from the share using the removeParticipant(_:) method, and then save the updated share to iCloud.

Deleting/Leaving a share
 
 
Q