I want to use Share
functionally in my React Native application but there is one exception, I don't want to share a content from my app, I want to share content from another app to my app, how is it possible to show my App in share sheet suggestions and handle shared data?

- 2,958
- 2
- 15
- 24
2 Answers
Adding your own Share Extension (iOS) or Share Intent (Android) to a React Native app is a little tricky, unfortunately. On iOS for example, this requires setting up a whole app extension including some native code which often ends up very decoupled from the rest of the React Native app.
See here for Android documentation and here for iOS documentation on the native parts.
There are some third-party libraries like react-native-share-extension that make this somewhat easier, even though it still requires some set-up. If you're using Expo, all solutions might end up being problematic due to the required app extension on iOS which might even be complex to setup using Expo config plugins (even though it's probably possible!).
Another problem you might face is that, at least on iOS, the amount of memory a Share Extension can use is very limited for a React Native app. Even a very basic extension might be killed by the OS due to an out of memory signal. A relatively easy way (which still requires a lot of native code) to circumvent this might be to simply link into your app once someone clicks on your share extension, instead of adding actual native UI for the modal of the iOS extension (which requires more memory). Here's a Medium article of someone who's done this already (and faced the same issues).

- 1,068
- 10
- 25
-
Thanks for your answer, rn-share-extension seems very old package – Leri Gogsadze Apr 26 '23 at 14:47
i used this package to implement share extension for both ios and android . https://github.com/meedan/react-native-share-menu

- 11
- 2
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 23 '23 at 06:10
-
Do you know if it's possible to not open the App and just show only one screen instead? – Leri Gogsadze May 24 '23 at 13:34
-
in index.share.js i am redirecting it to app` ShareMenuReactView.data().then(({ mimeType, data }) => { ShareMenuReactView.continueInApp({ shareInfo: data }); });` may be we can perform our logic here – Adnan Ashraf May 25 '23 at 05:41