Swapnil Panchal
Swapnil Panchal

Reputation: 407

How to send a message to multiple recipients in react native

I am implementing an application which sends SMS to multiple recipients from react native app for IOS.

I am using this library React-native-communication

please answer this question.

Thank you in advance.

Upvotes: 2

Views: 3217

Answers (2)

denisas
denisas

Reputation: 219

Or you can use Linking from 'react-native':

const onPressSendMessage = () => {
  let numbers = '';

  contacts.forEach((phoneNumber: string) => {
    numbers += `${phoneNumber},`;
  });
  numbers = numbers.slice(0, -1);

  const url = (Platform.OS === 'android')
    ? `sms:${numbers}?body=${text}`
    : `sms:/open?addresses=${numbers}&body=${text}`;

  Linking.canOpenURL(url).then((supported: boolean) => {
    if (!supported) {
      console.log('Unsupported url: ', url);
    } else {
      Linking.openURL(url).then(() => {
        navigateBack(); // or something else
      });
    }
  }).catch((err: string) => console.log('An error occurred', err));
}

Upvotes: 2

Tyler
Tyler

Reputation: 907

Have you checked out the react-native-sms package?

Its SMS.send function supports an options parameter that can handle multiple recipients. https://github.com/tkporter/react-native-sms#using-the-module

Upvotes: 1

Related Questions