Open shreejala-gurzu opened 2 years ago
The same behavior happens in my app. Please let me know the solution.
Same issue here.
i removed clearReceivedFiles, dont know why, so bad lib
just comment AppState addEventListener
then place
this.getFileNames(handler,errorHandler, "");
without any conditions dont use clearReceivedFiles()
Now its working...
useEffect(() => { ReceiveSharingIntent.getReceivedFiles( (data: any) => { console.log("received data", data); }, (err: any) => { console.log("err", err); }, ShareMedia, ); return () => { ReceiveSharingIntent.clearReceivedFiles(); }; }, []);
Initially, ReceiveSharingIntent.getReceivedFiles() returns the shared file. But after the clearReceivedFiles() function is called on unmount, ReceiveSharingIntent.getReceivedFiles() does not return any file on sharing. However, if we restart the app, it works just fine.
please put ReceiveSharingIntent.clearFileNames() in clearRecivedFiles function of ReceiveSharingIntent.tsx file and comment the isClear=true so it will work with android
just comment AppState addEventListener
then place
this.getFileNames(handler,errorHandler, "");
without any conditions dont use clearReceivedFiles()
Now its working...
Thank you so much, this is the actual solution for the issue.
useEffect(() => { ReceiveSharingIntent.getReceivedFiles( (data: any) => { console.log("received data", data); }, (err: any) => { console.log("err", err); }, ShareMedia, ); return () => { ReceiveSharingIntent.clearReceivedFiles(); }; }, []); Initially, ReceiveSharingIntent.getReceivedFiles() returns the shared file. But after the clearReceivedFiles() function is called on unmount, ReceiveSharingIntent.getReceivedFiles() does not return any file on sharing. However, if we restart the app, it works just fine.
please put ReceiveSharingIntent.clearFileNames() in clearRecivedFiles function of ReceiveSharingIntent.tsx file and comment the isClear=true so it will work with android
This solution worked, but the thing is that this library has its fair share of bugs and unexpected behaviors. Is it still maintained? is there someone who's still merging fixes and releasing new versions? because as far as I know, this library is the only decent library that can do sharing intents without much hassle and without resorting to creating your own native library. but the problem is that it contains critical bugs that still aren't fixed and merged in a public release yet, it requires some internal fixes, for me I've externalized the package in my project and to be honest it's not really a good idea to throw an externalized and unmaintained library.
just comment AppState addEventListener
then place
this.getFileNames(handler,errorHandler, "");
without any conditions dont use clearReceivedFiles()
Now its working...
This solution is working for me, thanks!
useEffect(() => { ReceiveSharingIntent.getReceivedFiles( (data: any) => { console.log("received data", data); }, (err: any) => { console.log("err", err); }, ShareMedia, ); return () => { ReceiveSharingIntent.clearReceivedFiles(); }; }, []); Initially, ReceiveSharingIntent.getReceivedFiles() returns the shared file. But after the clearReceivedFiles() function is called on unmount, ReceiveSharingIntent.getReceivedFiles() does not return any file on sharing. However, if we restart the app, it works just fine.
please put ReceiveSharingIntent.clearFileNames() in clearRecivedFiles function of ReceiveSharingIntent.tsx file and comment the isClear=true so it will work with android
This clearFileNames
method is the solution. It's almost like the creator of this package implemented it and then forgot to expose it to the JS runtime and use it. I ended up cloning this repo and exposing clearFilesNames
in ReceiveSharingIntent.ts
and then calling it inside the getReceivedFiles
callback once I've extracted the shared data.
Without doing this, every time you switch from another app to your app, the share listener will fire because the shared data never gets cleared.
im still facing the same issue after calling the clearReceivdFiles method i dont get new data until i reload the app
useEffect(() => { ReceiveSharingIntent.getReceivedFiles( (data: any) => { console.log("received data", data); }, (err: any) => { console.log("err", err); }, ShareMedia, ); return () => { ReceiveSharingIntent.clearReceivedFiles(); }; }, []); Initially, ReceiveSharingIntent.getReceivedFiles() returns the shared file. But after the clearReceivedFiles() function is called on unmount, ReceiveSharingIntent.getReceivedFiles() does not return any file on sharing. However, if we restart the app, it works just fine.
please put ReceiveSharingIntent.clearFileNames() in clearRecivedFiles function of ReceiveSharingIntent.tsx file and comment the isClear=true so it will work with android
This
clearFileNames
method is the solution. It's almost like the creator of this package implemented it and then forgot to expose it to the JS runtime and use it. I ended up cloning this repo and exposingclearFilesNames
inReceiveSharingIntent.ts
and then calling it inside thegetReceivedFiles
callback once I've extracted the shared data.Without doing this, every time you switch from another app to your app, the share listener will fire because the shared data never gets cleared.
this didnt work for me im using the latest version of react native
useEffect(() => { ReceiveSharingIntent.getReceivedFiles( (data: any) => { console.log("received data", data); }, (err: any) => { console.log("err", err); }, ShareMedia, ); return () => { ReceiveSharingIntent.clearReceivedFiles(); }; }, []); Initially, ReceiveSharingIntent.getReceivedFiles() returns the shared file. But after the clearReceivedFiles() function is called on unmount, ReceiveSharingIntent.getReceivedFiles() does not return any file on sharing. However, if we restart the app, it works just fine.
please put ReceiveSharingIntent.clearFileNames() in clearRecivedFiles function of ReceiveSharingIntent.tsx file and comment the isClear=true so it will work with android
this solution not working for IOS
useEffect(() => { ReceiveSharingIntent.getReceivedFiles( (data: any) => { console.log("received data", data); }, (err: any) => { console.log("err", err); }, ShareMedia, ); return () => { ReceiveSharingIntent.clearReceivedFiles(); }; }, []);
Initially, ReceiveSharingIntent.getReceivedFiles() returns the shared file. But after the clearReceivedFiles() function is called on unmount, ReceiveSharingIntent.getReceivedFiles() does not return any file on sharing. However, if we restart the app, it works just fine.