capacitor-plugins icon indicating copy to clipboard operation
capacitor-plugins copied to clipboard

Share plugin cannot call Share.share more then one time

Open tomer2141 opened this issue 3 years ago • 12 comments

Bug Report

Plugin(s)

@capacitor/share: 1.0.3

Capacitor Version

@capacitor/cli: 3.1.1 @capacitor/core: 3.1.1 @capacitor/android: 3.1.1 @capacitor/ios: 3.1.1

Platform(s)

android

Current Behavior

While calling Share.share for the first time it will work properly, but if I will try to run the share function again i will get an error: (using the chrome://inspect/#devices -> inspect -> console) Error: Can't share while sharing is in progress Error: Can't share while sharing is in progress

Expected Behavior

Be able to share more then one time

Other Technical Details

After digging up in the SharePlugin.java file i noticed that the activityResult callback is never called so the varriable isPresnteing will always be true after calling the share function for the first time

Additional Context

tomer2141 avatar Jul 16 '21 01:07 tomer2141

What’s your android version?

jcesarmobile avatar Jul 16 '21 07:07 jcesarmobile

@jcesarmobile A physical device running android 10

tomer2141 avatar Jul 16 '21 11:07 tomer2141

which option/app are you choosing for sharing?

jcesarmobile avatar Jul 16 '21 11:07 jcesarmobile

It happens when i press the cancel button and when i try to share with whatsapp, but those are the only two methods i checked...

tomer2141 avatar Jul 16 '21 12:07 tomer2141

After upgrading my android version to 11 it started working as expected.

tomer2141 avatar Jul 16 '21 14:07 tomer2141

I'll try to get an Android 10 device to test, it's the only one I don't have at the moment 😢

jcesarmobile avatar Jul 16 '21 17:07 jcesarmobile

It happens to us also. Any progress?

YogiBear52 avatar Jul 26 '21 08:07 YogiBear52

I'm also seeing this, but I'm using Android 11.

Edit: it seems to be crucial to actually wait for the returned Promise to be resolved. After changing my code to do that, it works fine here.

grigorig avatar Jul 26 '21 09:07 grigorig

FWIW this mostly needs a documentation update I guess. I also noticed that just awaiting isn't cutting it, is this possibly optimized away?

grigorig avatar Jul 26 '21 10:07 grigorig

Waiting for promise dont work for me, any news ?

kevinfavv avatar Aug 09 '21 13:08 kevinfavv

any updates on this bug?

mukul-myhq avatar Mar 07 '22 07:03 mukul-myhq

I encountered this issue, but I found that it was caused by an outdated version of the Facebook connect plugin (ionic-native/facebook + cordova-plugin-facebook-connect) somehow blocking/absorbing all the ActivityResults. For me, it was also causing issues with <input type="file"> and other things that rely on opening other activities.

Upgrading the plugin to latest seems to have fixed it for me.

henry-alakazhang avatar Mar 16 '22 04:03 henry-alakazhang

any updates on how to solve it?

rkundnani avatar Aug 25 '22 05:08 rkundnani

share popup should occur only if a specific button is clicked in capacitor.In my app once I click share button to share file, then again If I leave that screen and again start from home screen , it is showing me share popup even before clicking the share button?Is there any way to close this popup from the background ?

shikha2408 avatar Sep 20 '22 09:09 shikha2408

Closing since I can't reproduce and some users say it's resolved. If somebody is still facing the same problem, create a new issue and provide a sample app where the issue can be reproduced. Make sure you are using await on the share call and don't call it again until the first one resolved.

jcesarmobile avatar Sep 20 '22 17:09 jcesarmobile

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar Oct 20 '22 18:10 ionitron-bot[bot]