How to use notification to notify shared container changes in cloudkit?

I would like to create a private container and share a zone between two users with different iCloud accounts. All changes made by one would be notified with push notifications to the other user's db. Both could change the same information.

Exactly as it is done in this apple project. https://developer.apple.com/documentation/cloudkit/shared_records/sharing_cloudkit_data_with_other_icloud_users

However, I have been reading this code for days and I am stuck on it, it is extremely complicated for my level.

I would really like to know if there is any simple project that uses the same idea to build this logic with swiftui.

Answered by DTS Engineer in 805805022

In CloudKit, there are two types of sharing, zone sharing and hierarchical sharing, which are quite different. For more information on this topic, please see the following WWDC2021 session:

The sample you mentioned demonstrates hierarchical sharing. If you target to use zone sharing, see the following sample instead:

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

In CloudKit, there are two types of sharing, zone sharing and hierarchical sharing, which are quite different. For more information on this topic, please see the following WWDC2021 session:

The sample you mentioned demonstrates hierarchical sharing. If you target to use zone sharing, see the following sample instead:

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

when I am sharing a link, this message appears in the console "connection invalidated"

This happens after I click to generate a link in the sharing interface I click cloudkit share " You cannot get the URL of a share until it's been saved to the server

Copy Link failed: Couldn't retrieve shareURL for item:<_SFCKShareCollaborationItem: 0x600003747300> identifier:946489CB-BF61-48D4-BA49-3F405B38AE0B, type:1, itemProvider:<_UISharingControllerActivityItemProvider: 0x600002926c30> {types = ( UTCollaborationOptionsType, "com.apple.cloudkit.sharingsupport.container", "com.apple.cloudkit.sharingsupport.post" )}, activityItem:<_UIActivityItemsConfigurationActivityItemProvider: 0x105124a90>, placeholderActivityItem:https://www.apple.com/icloud/, options:(null), sendCopyRepresentation:(null), canAddPeople:1 (null) connection invalidated "

"connection invalidated"

This message may happen when the sharing UI loses the connection to the share link delivery process (Mail, Messages, etc). It may or may not be a real issue because the UI can create a new connection, if needed.

" You cannot get the URL of a share until it's been saved to the server Copy Link failed: ..."

This message means what it says. The share link is only available after the share (CKShare) is saved, so you might check if your code saves the share correctly.

In any case, you might start with verifying the issue with the sample code – If you can reproduce the issue with the sample, please share the detailed steps. Otherwise, you can compare the sample with your own implementation to figure out how you do differently.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

How to use notification to notify shared container changes in cloudkit?
 
 
Q