react-native-share: Cannot share image on whatsapp iOS, even without message.

Steps to reproduce

I’m trying to share an image to whatsapp. According to https://github.com/react-native-community/react-native-share/issues/280#issuecomment-581819939, you cannot share message and image at the same time.

I’ve tried to share message only, and it is working.

        Share.shareSingle({
            message: ‘Hello’,
            social: Share.Social.WHATSAPP,
            whatsAppNumber: ''
        });

But if I tried to share an image only, it doesn’t work. Nothing is happening. Whatsapp not even opening.

        Share.shareSingle({
            url: fileUrl
            social: Share.Social.WHATSAPP,
            whatsAppNumber: ''
        });

I also tried using the Share.open then select Whatsapp, and it’s working.

Share.open({ url: fileUri })

This issue only happens on iOS, it’s working on Android.

Expected behaviour

Able to share image on whatsapp

Actual behaviour

Not sharing image on whatsapp

Environment

  • React Native version: 0.62.2
  • React Native platform + platform version: iOS 13.6

react-native-share

Version: 3.7.1

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 25 (2 by maintainers)

Most upvoted comments

To share images on ios via whatsapp, you just need to pass options without message attribute. I had to put platform check

if(Platform.OS == 'ios'){
    delete options.message
}

@mssha no, you can, i’m using 3.6.0 and i’m able to shareSingle a base64 image to WhatsApp on iOS.

It seems like sharing to WhatsApp on iOS with Share.shareSingle only supports video and text. Looking at WhatsAppShare.m, UIDocumentInteractionController is only used for video, and anything else is passed in as the text param.

That means I can’t share a local image to WhatsApp, right? Am I missing something?

@vajid-khan thank you for your help. It works 😃

Hi, I am having similar issue on ios. Using version 3.7.0

const options = {
            title: 'Title',
            subject: 'subject',
            url: `data:image/png;base64,${base64}`,
            message: 'message',
        }

        Share.open(options)
            .catch(error => console.log({ error }))

I am selecting whatsapp from picker. With this on ios only message is passed not image Its working fine on android