react-nativeexposocialshare

Is it possible to share both text message and image using expo-sharing?


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 ?


Solution

  • 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 :)