react-native-share-menu icon indicating copy to clipboard operation
react-native-share-menu copied to clipboard

continueInApp() only works every other time

Open vonstring opened this issue 3 years ago • 5 comments

I'm having issues with continueInApp only working every other time. First time it will open the main app as expected. The next time I share something, the share extension just closes as soon as continueInAppis called, and the main app never opens.

I've worked around it by dismissing the extension a while after calling continueInApp:

        ShareMenuReactView.continueInApp();
        setTimeout(() => {
          ShareMenuReactView.dismissExtension();
        }, 500);

which makes the main app open every time. Am I missing something? (very possible)

vonstring avatar Dec 17 '22 18:12 vonstring

@vonstring I've noticed the same thing from my end. I'm seeing the following behavior on iOS (haven't tested Android yet)...

For images, the ShareMenuModuleComponent always loads properly the first time upon clicking my app's icon in the share sheet. However, if I keep my phone's Photos app open and try again, the first time trying to share a second image always fails to bring up the ShareMenuModuleComponent. If I click my app's icon in the share sheet a second time after this first failure, it seems to always work as expected.

The below screenshot is the output from my Metro terminal. The first call to the index.share.js file is unsuccessful (hence there's no log of ShareMenuModuleComponent running) and the second call to index.share.js is successful and all works according to plan. Again, the failures always seem to occur after a successful journey into the app.

Screen Shot 2023-01-13 at 12 50 25 PM

Note that if I close the Photos app and start fresh for a second image, it always seems to work. So the issue is when trying a second time without closing the native Photos app.

The above behavior is the exact same for files in the native iOS Files app. However I've noticed that I can't get audio files from Voicemail to ever succeed the second time. I need to navigate out of Voicemail and then come back in for a second audio file upload to work. Again, first time always works, successive tries (without closing the app) always fail.

@caiosba @Gustash please let us know if there's a better way to utilize your APIs (like dismissExtension referenced above) or if there's a native iOS fix to completely wipe the state clean after the first, successful pass through the share extension flow.

I appreciate the support!

Dan

DanC5 avatar Jan 13 '23 20:01 DanC5

@DanC5 were you able to solve it?

jorgegvallejo avatar May 04 '23 14:05 jorgegvallejo

@DanC5 were you able to solve it?

I was not able to solve this, outside of the work around referenced in the original post. A useEffect in my code making the calls looks like this...

useEffect(() => {
    ShareMenuReactView.data()
      .then(({ data }) => {
        const [shareData] = data as unknown as ShareData[];

        if (shareData.data && shareData.mimeType) {
          ShareMenuReactView.continueInApp();
          setTimeout(() => ShareMenuReactView.dismissExtension(), 500);
        }
      })
      .catch(err => {
        console.log(err);
        ShareMenuReactView.dismissExtension();
      });
  }, []);

DanC5 avatar May 04 '23 15:05 DanC5

I see the same issue :|

GuySerfaty avatar Jun 06 '23 09:06 GuySerfaty

This is the fix for iOS

https://github.com/meedan/react-native-share-menu/pull/156/commits/373a30d9596796011ff31bbacb1f7f70f59e509c

durdevic avatar Jun 25 '23 14:06 durdevic