ZoneSharing CloudKit UI

I am trying to use Zone Sharing in my SwiftUI app. I have been attempting to get the UICloudSharingController to show an initial share screen to pick users and the mechanism to send the invitation.

From the documentation, it appears that the UICloudSharingController .init(preparationHandler:) API is deprecated so I am not using that approach. Following the Apple documentation, I am creating a Zone Share and NOT saving it and presenting using the UICloudSharingController(share:container:) API. However, this presents a UI that is the 'mgmt' API for a Share. I can get to the UI I was expecting by tapping on the 'Share with More People' option, but I want to start on that screen for the user when they have not shared this before.

So, I found an example app from Apple at: https://github.com/apple/sample-cloudkit-zonesharing. It has the same behavior. So we can simply discuss this problem based on that example code.

How do I get the next View presented when tapping 'Share Group' to be the invitation for new users screen?

Here is the UI it presents initially:

And here is the UI (on the bottom half of the screen) I am trying to start the share process with:

Thanks,

Charlie

Answered by DTS Engineer in 854678022

Yeah, UICloudSharingController.init(preparationHandler:) was deprecated. Depending on which UI framework you are using, you can consider using ShareLink, UIActivityViewController, or NSSharingServicePicker to create a new CloudKit share. This is mentioned here. Feel fee to follow up if you have further question when going along the path.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Accepted Answer

Yeah, UICloudSharingController.init(preparationHandler:) was deprecated. Depending on which UI framework you are using, you can consider using ShareLink, UIActivityViewController, or NSSharingServicePicker to create a new CloudKit share. This is mentioned here. Feel fee to follow up if you have further question when going along the path.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Ziqiao:

Thank you for getting back to me on this issue. I have moved my code to use ShareLink; I am using SwiftUI and this looks like the best match.

I was hoping to be able to use the CKShare to track who was invited to the Share. But, in my experiments, I am not seeing any invitations reflected into the CKShare's participants before they accept the invitation.

Is there any way to use ShareLink to populate the CKShare's participants when they are 'invited' but not yet have accepted the invitation?

[I am still working on getting 'accepting' working in my test environment, so I might still have more questions once I can see that part of the workflow working].

Thanks in advance,

Charlie

In the case where an owner has successfully invited a participant and the participant has not accepted yet, the acceptance status of the participant should be shown as Invited in the UI of UICloudSharingController or NSSharingService. You should also be able to grab the participant from the participants property of the CKShare instance, and the acceptanceStatus of the participant should be .pending. Both cases are demonstrated in the ParticipantView of the sample code.

Probably relevant, if your issue is actually related to the access to the user identity in CKShare on the version 26 systems, there is a change in that regard. See this post for more details.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

ZoneSharing CloudKit UI
 
 
Q