Reputation: 247
I was trying to send sms without opening sms app. I have tried expo sms but no luck. I have also tried few other packages but still nothing...is there a way?
Upvotes: 1
Views: 2934
Reputation: 368
You can use this module npm install react-native-sms --save && react-native link react-native-sms
Next step add some code:
import SendSMS from 'react-native-sms'
someFunction() {
SendSMS.send({
body: 'The default body of the SMS!',
recipients: ['0123456789', '9876543210'],
successTypes: ['sent', 'queued'],
allowAndroidSendWithoutReadPermission: true
}, (completed, cancelled, error) => {
console.log('SMS Callback: completed: ' + completed + ' cancelled: ' + cancelled + 'error: ' + error);
});
}
Upvotes: -1
Reputation: 2972
Looks like this library is working fine and reached the goals to send a message without going into the default message environment.
var phoneNumbers = {
"addressList": ["+911212121212", "+911212121212"]
};
var message = "This is automated test message"
SmsAndroid.autoSend(
phoneNumbers,
message,
(fail) => {
console.log('Failed with this error: ' + fail);
},
(success) => {
console.log('SMS sent successfully');
},
);
Upvotes: 2