React native app to receive share links from apps like youtube

I am new to React native. I am developing an app to receive shared url like in youtube share which shares the url.like this I have added the code to register receive activity in xml like this

 <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
          <action android:name="android.intent.action.SEND" />
          <category android:name="android.intent.category.DEFAULT" />
          <data android:mimeType="text/plain" />
 </intent-filter>

But in my App.js code how could i receive the data and do further processing.

728x90

3 Answers React native app to receive share links from apps like youtube

You can do this with react-native-share-extension

3 weeks ago

You can use Deep Linking from react-navigation. Check this Article for example.

2 weeks ago

So get the initial launched url you can actually use the inbuild react-native functionality of Linking where in you main/root file you can just listen you initial launch params as

   componentDidMount = () => {
       Linking.getInitialURL().then((url) => {
       // if your app was launched from the share you will get the text
       // else url will be null
       if (url) {
         console.log('shared string/text is ', url);
       }
     }).catch(err => console.error('An error occurred', err));
   }

React native Linking docs link

2 weeks ago