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?
Question posted in React native
The official React Native documentation can be found here.
The official React Native documentation can be found here.
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).
i used this package to implement share extension for both ios and android .
https://github.com/meedan/react-native-share-menu