React-Native: The subject line of email is same as the message contents using Share.share

Viewed 413

It's a pretty strange problem I have been facing. I am using Share.share which takes message, subject(ios) and title (for gmail) as an argument. In the android it works fine. i.e. The subject line is "I am the title" whereas the message body is "I am groot". But in iOS, the subject line is always same as the message, like the screenshot shown below:Subject line same as the message body Any help would be highly appreciable. Thanks in advance.

onShare = async () => {
    try {
      await Share.share(
        {
          message: "I am groot",
          title: "I am the title",
        },
        {
          subject: "I am the subject line",
        }
      );
    } catch (error) {
      ...
    }
  };
  
2 Answers

Instead of importing Share from react-native, when I imported it from react-native-share, it fixed my problem.

As per the documentation, Share title property is used only as a title for the message. To set the email subject you need to set the subject property in the options object (note: this only works on IOS)

Related