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

[Android] Share.open always return success: false.

Open AndraLuana opened this issue 8 months ago • 2 comments

We are encountering an issue with the react-native-share library on Android where the share action is incorrectly flagged as "cancelled" despite the user successfully sharing content via email or other certain share targets. Here is the specific behavior:

Steps to reproduce

  1. Capture a screenshot or image using react-native-view-shot.
  2. Trigger the share dialog using react-native-share.open() with the email option or other share targets.
  3. Select the email share option and send the email successfully.
  4. The share is completed, but the result indicates that the user "cancelled" the action or "did not share."

Expected behavior

When the user shares via email (or other targets), the share should be successfully recorded as completed, and the appropriate event should be triggered, rather than being flagged as cancelled.

Actual behavior

The share action returns with an error message indicating that the user cancelled the action or did not share, even though the email has been sent successfully. Logs:

LOG User cancelled the share action LOG Captured URI: file:///data/user/0/......./cache/ReactNative-snapshot-image7710230649870402463.jpg ERROR Share failed: [Error: User did not share]

Environment

  • React Native version: "react-native": "0.74.7"
  • React Native platform + platform version: Android Pixel_6_API_30

react-native-share

Version: "12.0.9"

Code:

const onShare = useCallback(() => {
    if (ref?.current?.capture) {
      ref.current
        .capture()
        .then((uri) => {
          return Share.open({
            title: <TITLE>,
            message: <URL>,
            url: uri,
          })
            .then(() => {
                <THIS_NEVER_GETS_EXECUTED> // even though the asset was successfully shared
            })
            .catch((error) => {
              console.error('Share failed:', error);
            });
        })
        .catch((error) => {
          console.error('ViewShot capture failed:', error);
        });
    }
  }, [.....]);

AndraLuana avatar Apr 28 '25 10:04 AndraLuana

+1 bug

tuannguyen1902 avatar May 12 '25 04:05 tuannguyen1902

+1 bug

GeoFro avatar May 15 '25 13:05 GeoFro

+1 bug

highstrungscorpio avatar Jun 19 '25 17:06 highstrungscorpio

+1 bug

tuannguyen-99 avatar Jun 27 '25 09:06 tuannguyen-99

+1 bug

VishnuNCS avatar Jul 07 '25 02:07 VishnuNCS

+1 bug, I have the same bug

wilmer-estrada-dev avatar Jul 18 '25 19:07 wilmer-estrada-dev

Any update for this bug?

tuannguyen1902 avatar Jul 30 '25 03:07 tuannguyen1902

I gave on this bug and just do this now:

catch (error) {
      if (error && typeof error === "object" && "message" in error) {
        const errorMessage = (error as Error).message;
        if (!errorMessage.includes("User did not share")) {
          console.error("Error sharing CSV:", error);
        }
      }
    }

niteshbalusu11 avatar Jul 31 '25 19:07 niteshbalusu11

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and i will leave this open

github-actions[bot] avatar Sep 30 '25 02:09 github-actions[bot]