react-native-share: SingleShare WhatsApp on iOS not working

Steps to reproduce

import Share from 'react-native-share';

const shareOptions = {
    title: 'Share via',
    message: 'some message',
    social: Share.Social.WHATSAPP,
};
Share.shareSingle(shareOptions);

Expected behaviour

It should open the WhatsApp

Actual behaviour

App Crashes

Environment

  • React Native version: 0.59.2
  • React Native platform + platform version: iOS 12.3.1

react-native-share

Version: 1.1.3

RCTFatalException: Exception '*** -[__NSCFConstantString stringByAppendingString:]: nil argument' was thrown while invoking shareSingle on target RNShare with params (
        {
        message = "Hey! I\U2019m really exited to share the new app for stu...: 

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 27 (4 by maintainers)

Most upvoted comments

Well it’s installed, that’s the issue… Opening via Linking.openURL('whatsapp://send?text=‘hello from RN’) works just fine.

On Thu, Oct 24, 2019 at 1:17 AM João Marins notifications@github.com wrote:

AppStore is opened when the app is not installed

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/react-native-community/react-native-share/issues/555?email_source=notifications&email_token=AAELHTNMBAWJBADY7ZJXJBDQQDLRPA5CNFSM4IG4Y7J2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECDFRAY#issuecomment-545675395, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAELHTMWPXI7KJ7Y5XDQFZLQQDLRPANCNFSM4IG4Y7JQ .

It seems like Whatsapp require an url instead of a message ? But it opens the AppStore for me instead of Whatsapp 😦 (v1.2.1)

const shareWhatsApp = {
  title: '...',
  message: '...http://test.com',
  social: Share.Social.WHATSAPP,
  url: 'http:://test.com',
}

Hi @imbudhiraja , i got a similar problem a time ago, and as i remember is was related to a specific param that WhatsApp on IOS doesn’t recognize. I ended using something similar to this:

export const shareImage = async (image, message, title, subject) => {
  const shareInfo = {
    title,
    url: image,
    subject,
  };

  const shareResponse = ShareCustom.open(shareInfo)
    .then(res => ({ error: '', payload: res, success: true }))
    .catch(err => ({ error: (err && err.error) || 'User did not share', payload: {}, success: false }));

  return shareResponse;
};

I think you can omit the url param without any problem on your case. Btw, let me know if this helps you.

share single WhatsApp opens app store for me. And WhatsApp is installed. version 1.2.1. I am not using react-native 0.60 yet

I don’t know if still relevant but on IOS you need to set on Info.plist

<key>LSApplicationQueriesSchemes</key>
  <array>
    <string>whatsapp</string>
  </array>

To be able to open the WhatsApp

Hi,

I am also facing the similar issue with Whatsapp on iOS. Only one works either message or url. Is there any workaround for sharing both.

Thanks.

This looks like how WhatsApp handle this kind of content, when using their share api. Unfortunately i was able to share a image to WhatsApp, removing the message param.

Same problem here, and a tried with version 2.0