getInitialShare call back is empty array in ios
In Ios callback is {"data": []} in android callback is {"data": "https://youtu.be/kOvOWqzCRq8", "mimeType": "text/plain"}
yes i have same issue ,please anyone help on this
The same for me. Has somebody resolved the issue?
Same for me
Is there anyone solved this problem?
Found a solution that works for me (initial testing in iOS emulator only) based on this comment, which identifies that the example project code doesn't work as expected.
For iOS, you can do something like the following:
useEffect(() => {
ShareMenuReactView.data().then(({ data }) => {
// data is a list of objects shaped like { data: ..., mimeType: ...}
// Initially only caring about the first item, and disregarding cross-platform compatibility below:
const sharedItem = data[0];
setSharedData(sharedItem.data);
setSharedMimeType(sharedItem.mimeType);
});
}, []);
I found my solution in the configuration. I miss a part to include which is in HostAppURLScheme. Whatever you add in your app info.plist URL scheme, pls double-check that you ve added it with :// at the end of your HostAppURLScheme in your share extension info.plist
<key>HostAppBundleIdentifier</key>
<string>com.github.meedaan.ReactNativeShareMenuExample</string>
<key>HostAppURLScheme</key>
<string>ShareMenuModule://</string>
<key>NSExtension</key>
After I added it, I run pod install, build the app in xcode and then delete and re-install the app. Then I saw the data in the console.
Ps: I read the data with @freethejazz example...
Had a similar oversight as @Seration: I forgot to add the "HostAppBundleIdentifier" in the Sharingextension plist file and only got {data: null} #as a result.
After adding it I can now read the data with this setup:
when app starts up on Share Event
useEffect(() => { ShareMenu.getInitialShare(handleShare) }, [])
when app is already running
useEffect(() => { const listener = ShareMenu.addNewShareListener(handleShare) return () => { listener.remove() } }, [])
Yeap,
HostAppBundleIdentifier ==> you app bundle id
and use group.<you app bundle id>
To clarify @anatooly comment. Avoid putting $(APP_BUNDLE_ID) in the SharingExtension plist. Just hardcode the string
<key>HostAppBundleIdentifier</key> <string>com.some.bundleid</string>