Use this RN component to send an SMS with a DeviceEventEmitter (SMS_STATUS_LISTENER). iOS and Android are both supported.
npm install react-native-sms-sender --save
Once everything is all setup, it's pretty simple:
SendSMS.send(myOptionsObject);
Key | Type | Platforms | Required? | Description |
---|---|---|---|---|
body |
String | iOS/Android | No | The text that shows by default when the SMS is initiated |
recipients |
Array (strings) | iOS/Android | No | Provides the phone number recipients to show by default |
import SendSMS from 'react-native-sms-sender'
//some stuff
someFunction() {
SendSMS.send({
body: 'The default body of the SMS!',
recipients: ['0123456789', '9876543210'],
});
//only for android |0:send,1:sent,2:delivered,3:errorSend,4:notDelivered|
let statusListener = DeviceEventEmitter.addListener('SMS_STATUS_LISTENER', function(status) {
console.log(status);
});
}