Let's use a basic todo app as an example - sharing a todo list. I have a share button (square with up arrow) that when the user taps I want the initial share sheet to appear. If I have to create and save the CKShare in order to pass it (albeit wrapped) to UIActivityViewController or ShareLink. The issue is that saving the CKShare incurs a network interaction and so there is a 1 - 2 second delay from the time the user taps the share button to the time the share sheet is displayed.

I note that in the Apple Reminders app, tapping the share button immediately brings up the share sheet and then if you select say Messages, it shows the share object inside the body with an activity spinner inside that object for a second before its ready to send. If you cancel and don't send, the share button remains and you can simply go through that same process again. That is, it doesn't appear to leave any zombie shares behind.

With the deprecation of UICloudSharingController .init(preparationHandler:) you suggested using ShareLink or UIActivityViewController. I can't figure out how to achieve the same thing as Apple Reminders where there is no delay between tapping the share button and presenting the share sheet due to having to create and save the CKShare object first (and in the case of using ShareLink, not leaving behind a CKShare zombie if the user does not actually send the invite).

Would greatly appreciate some guidance on this

2 Replies 2

First, your question should be posted a regular question.

The solution is to use NSItemProvider registerCKShare(container:allowedSharingOptions:preparationHandler:) and then pass that to the UIActivityViewController (or whatever the SwiftUI equivalent is). You setup the CKShare in the preparation handler. It won't be called until needed.

Oops, apologies I did post this incorrectly. Thank you for your response. I will give it a try.

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.