有没有办法在不打开短信应用程序的情况下发送短信?

Is there a way to send SMS without opening sms app in react native?

我试图在不打开短信应用程序的情况下发送短信。我试过 expo 短信但没有运气。我也尝试了其他几个包,但仍然没有...有什么办法吗?

看起来 this 库工作正常并达到了发送消息的目标,而无需进入默认消息环境。

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');
        },
    );

你可以使用这个模块npm install react-native-sms --save && react-native link react-native-sms

下一步添加一些代码:

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);
 
    });
}