When I share both JSON and plain text:
ShareButton(title: "JSON", shareItems: [ItemSource(dataToShare: shareInput)
,ItemSource(dataToShare: "sharing some text")
])
I get (iOS 16 vs. iOS 17):
where iOS 16
ShareExtension[9236:652213] [ShareSheet] ❗️itemProvider=<NSItemProvider: 0x280afa1b0> {types = (
"public.plain-text"
)}
and iOS 17 transfer:
❗️itemProvider=<NSItemProvider: 0x300f99e30> {types = (
"public.plain-text"
)}
Library: ShareExtension | Subsystem: com.myapp.containingdemo.ShareExtensionDemo | Category: ShareSheet
So again it's clear that the ShareInput is not transferred, but only the text.
For the result, I didn't manage to pass a ShareResult struct to NSItemProvider:
I just found
NSItemProvider(item: contactData as NSSecureCoding, typeIdentifier: UTType.vCard.identifier)
which probably works because contactData is known to iOS...
See this thread:
https://forums.developer.apple.com/forums/thread/24368
Again, transferring plain text was possible...
Main Question: How can I transfer my ShareInput struct from the HostApp to the extension (iOS 16 and later), and then my ShareResult struct from the extension back to the HostApp (iOS 16 and later)?
And how can the HostApp limit the possible sharing targets? I want neither persons nor actions to appear in the sharing dialog, just apps - preferably only my ContainingApp. This should be possible with a strict NSExtensionActivationRule, right?
(Bummer, it is not possible to upload the zipped demo project. Thus I'll need to upload to github...)
Topic:
App & System Services
SubTopic:
General
Tags: