Skip to content

Image didn't show in share model as clipboard if we pass value for urls as an array(Multiple images selected) #1583

@SujithKannaa98

Description

@SujithKannaa98

Hii, I am using below specifications for running the project
"react-native": "0.74.3",
"react-native-share": "^11.0.3",
API Level- 34, and
Mobile model- Oneplus Nord Lite 3 5g

I am facing the issue, while I am selecting multiple images for sharing through media, the selected images are not showing in share modal as clipboard images, But sharing is done perfectly ( like whatsapp, email etc). For single image it is showing in the share modal preview.
For references I have attached the screenshots below.

IMG_One
IMG_Two

code snippet:

const openGallery = () => {
    const options = {
      mediaType: "photo",
      selectionLimit: 4, // Limit to 4 images
    };

    launchImageLibrary(options, async (response) => {
      if (response.didCancel) {
        console.log("User cancelled image picker");
        return; // Exit early if the user cancels
      }
      if (response.errorMessage) {
        console.log("ImagePicker Error: ", response.errorMessage);
        return; // Exit early on error
      }
      console.log("Response...................", response);
      try {
        // Process selected images
        const imageArr = await Promise.all(
          response.assets.map(async (item) => {
            const base64Data = await RNFS.readFile(item.uri, "base64");
            return `data:${item.type};base64,${base64Data}`; // Use item.type for MIME type
            // return item.uri;
          })
        );
        // Prepare share options
        const shareOptions = {
          message: "Check out these images!",
          urls: imageArr, // The array of image data URLs
          subject: "Cart Details",
          failOnCancel: false,
        };

        // Share the images
        await Share.open(shareOptions);
        bottomSheetModalRef.current?.dismiss(); // Dismiss the modal if needed
      } catch (error) {
        console.log("Error processing or sharing images: ", error);
      }
    });
  };

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionstaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions