ajith-ab / react-native-receive-sharing-intent

A React Native plugin that enables React Native apps to receive sharing photos, videos, text, urls or any other file types from another app
MIT License
309 stars 112 forks source link

Opening app deep links #88

Open LPitonakova opened 3 years ago

LPitonakova commented 3 years ago

Hi,

I am trying to use your library alongside using deeplinks for my app. (like myapp://myPath) The library works well when I share any content with the app. However, on Android, I cannot get it to accept deeplinks.

On iOS, your library correctly understand the "myapp://myPath" link and sets the json received in React Native as:

{"content": "", "contentType": "WEBPAGE", "url": "myapp://myPath"}

However, on Android, this doesn't happen. I have added the intent filter in my AndroidManifest as I am supposed to:

<intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="myapp" />
</intent-filter>

When I call the link myapp://myPath from a browser on Android, the app opens, but the part ReceiveSharingIntent.getReceivedFiles() never gets called.

While whole react native code is:

export default function App() {

  useEffect(() => {
    /**
     * Get the shared content.
     * @param jsonArray_: JSON array in format [{ filePath: null, text: null, weblink: null, mimeType: null, contentUri: null, fileName: null, extension: null }]
     */
    ReceiveSharingIntent.getReceivedFiles(jsonArray_ => {  
      console.log(jsonArray_)
    }, 
    (error) => {
      //-- do nothing on error

    });
    console.log("-----")

  }, []);

    return (
    <NavigationContainer >
      <DrawerWrapper />
    </NavigationContainer>
  );
}

Am I missing anything that I am supposed to do on Android?