0

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?

Omar
  • 32,302
  • 9
  • 69
  • 112

1 Answers1

1

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.

philnash
  • 70,667
  • 10
  • 60
  • 88