简体   繁体   中英

(JQuery Mobile/ JavaScript) Mobile phone send sms at backend not working

Thank you for taking the time to read this post. Basically, I am trying to code a mobile app which one of its features requires making a mobile phone to send a message (local/overseas message) at the backend (without letting the "user" know). It's a company mobile phone (ios/android) and the number belongs to the company. Besides, the condition is offline.

I tried to use href tag to send the message but it doesn't work for me. Is there any way to achieve this?

Twilio developer evangelist here.

You can only use the device's APIs to send SMS messages from a user's number on Android. iOS does not let you do this in the background or hidden from the user.

For Android, I encourage you to follow this tutorial on sending SMS messages from Android .

The key point is that, if you have the SEND_SMS permission

<uses-permission android:name="android.permission.SEND_SMS" />

Then you can send an SMS message with these lines of code:

SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("phoneNo", null, "sms message", null, null);

If you are using JavaScript, presumably via cordova or similar, then you will likely need a plugin to achieve this. The cordova-sms plugin seems like it might work for you on Android.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM