Nothing is caught in the listener when using continueInApp()
I'm trying to share directly from Safari into the app without using a share sheet. In share.tsx I have
import React, { useState, useEffect } from "react"
import ShareMenu, { ShareMenuReactView } from "react-native-share-menu"
function ShareScreen() {
ShareMenuReactView.continueInApp()
return <></>
}
export default ShareScreen
In app.tsx, I have a listener and handler that work on Android.
// Catch shared information
const handleShare = useCallback((item: SharedItem) => {
if (!item || !item.data) {
return
}
navigationRef?.current?.navigate("import", { url: item.data })
}, [])
useEffect(() => {
!initializing && ShareMenu.getInitialShare(handleShare)
})
useEffect(() => {
const listener = ShareMenu.addNewShareListener(handleShare)
return () => {
listener.remove()
}
}, [initializing])
But when I share from Safari in iOS, handleShare never gets called. The listener never "hears" the data getting passed. The app does open properly. What am I missing? How do I properly use continueInApp()?
@raquelmsmith did you get this to work properly? I have it set up but when trying to share it the app does not open.
I follow this link and has the same problem too: https://github.com/meedan/react-native-share-menu/issues/106#issuecomment-782034472
- The problem is the mismatch between share extension' surlscheme and AppDelegate.m's urlscheme.
if ([urlString hasPrefix:urlScheme]) {My problem solved.
@solominh Unfortunately I was not able to get the project built after modifying this file.
@raquelmsmith What is in your Info.Plist file of this extension? We had the same problem and we were missing the :// in the HostAppURLScheme field.
We had the same issue which was caused by the ordering of the CFBundleURLSchemes entries in our Info.plist. Once they were ordered so the full bundleId came first, it started to work.
A trick is to set a project-level user-defined config setting, then reference in your main plist and app extension plist.
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>$(PARENT_APP_BUNDLE_IDENTIFIER)</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$(PARENT_APP_BUNDLE_IDENTIFIER)</string>
<string>someOtherScheme</string>
</array>
</dict>
</array>
Then in your share extension Info.plist
<key>HostAppBundleIdentifier</key>
<string>$(PARENT_APP_BUNDLE_IDENTIFIER)</string>
<key>HostAppURLScheme</key>
<string>$(PARENT_APP_BUNDLE_IDENTIFIER)://</string>
Hey @raquelmsmith were you able to resolve your problem? I'm also in this roadblock
I haven't been using continueInApp() so I can't help with this issue, sorry.
Oddly enough my setup worked after a clean and restart :P
For us, it was that we weren't also calling ShareMenuReactView.dismissExtension() after the call to continue in app. This was putting Safari into a bad state. By calling this method right after continueInApp() we were able to reset the modal state in Safari.
please help... kindly explain i am trying to send extraData in my app from share by using continueInApp but i can't receive that data in my app. can anyone please help. @JohnGrisham @jojonarte @raquelmsmith @dburdan @gilsonviana-modus @solominh @kubik369
ShareMenuReactView.data().then(item => {
ShareMenuReactView.continueInApp({
anykey:"anyValue",
data: item.data[0].data,
mimeType: item.data[0].mimeType,
});
});
We were facing the same issue. Our problem was that the main target and the share extension target were not in a properly named group for our debug build. The group HAS TO BE EXACTLY named group.YOUR_APP_BUNDLE_ID, so if your main app is com.app.your, it needs to be group.com.app.your and if you have a debug build with bundle id com.app.your.debug you need another group group.com.app.your.debug
@filipgerat are you ShareMenu.getInitialShare? The issue is that getInitialShare works but listeners don't fire off. my groups settings are properly setup but the listener doesn't kick off. Hence I have an app://OpenURL route that calls getInitialShare when it is opened.