1

Sharing.shareAsync(url, options)

Opens action sheet to share file to different applications which can handle this type of file.

Arguments url (string) -- Local file URL to share. options (object) -- A map of options: mimeType (string) -- sets mimeType for Intent (Android only) dialogTitle (string) -- sets share dialog title (Android and Web only) UTI (string) -- (Uniform Type Identifier) the type of the target file (iOS only)

This is what they say on their page. I dont see any option to share text message along with a local image. Is there any way to share both the image and text message ?

lonecruisader
  • 408
  • 5
  • 13

2 Answers2

2

According to the docs, you should be able to use it like so for Android:

url = '<image-to-be-shared-local-url>';
messageText = 'Text that you want to share goes here';
const options = {
   mimeType: 'image/jpeg',
   dialogTitle: messageText,
};
Sharing.shareAsync(url, options);

But I would recommend to use react-native-share as this is more widely used and has more options for you to experiment with.

Here is the library documentation

Hope this helps :)

Sahith Kurapati
  • 1,617
  • 10
  • 14
1

react-native-share still not compatible with expo. you have to use either expo-sharing or Share from react-native.

Example:

ShareMessage = async () => {
    if (Platform.OS === "android") {
      Share.share({
        message: API.base_url + this.state.ShareProductName, // supporting android
        url: this.state.share_images[0], // not supporting
        title: this.state.ShareProductName,
      })
        .then((result) => console.log(result))
        .catch((errorMsg) => console.log(errorMsg));
      return;
    } else if (Platform.OS === "ios") {
      Share.share({
         message:API.base_url + this.state.ShareProductName,
         url: this.state.share_images[0],
        title: this.state.ShareProductName, // not supporting
       })
      
       .then((result) => console.log(result))
        .catch((errorMsg) => console.log(errorMsg));
      return;
    }
  };
Sayan Dey
  • 173
  • 1
  • 8