How to send SMS without opening SMS native android app

Hi All,

I have used the https://github.com/cordova-sms/cordova-sms-plugin plugin to send SMS through ionic android app. The problem is that it opens the native android SMS messaging app to send it. I want that my app sends SMS without opening any other app.

var intent = ā€˜ā€™; //leave empty for sending sms using default intent

1 Like

Hi sorry I did not get you :frowning:
Why is intent even used?

In the Javascipt when:
var intent =ā€˜INTENT’ > native android SMS messaging
var intent = ā€˜ā€™ > send SMS without open any other app

$window.sms.send(number, message, intent, success, error);

4 Likes

Thanks for this - the documentation on the plugin is lacking the explanation for the ā€˜intent’ parameter - this make sense, so thanks for clarifying.

Hi Jimibi,

Thanks alot man!

I will edit the documentation of this plugin.

Hi! I am trying to use the sms plugin, but it’s not working. Do you mind offering some help?

I followed everything on github and put the two pieces of code in the following spots: the HTML went into my view, and the JAVASCRIPT went into my app.js ionic file after this line: ā€œ$urlRouterProvider.otherwise(’/tab/home’);ā€.

Nothing seems to be working. I also went onto github and cloned the cordova-sms-plugin-test, which also doesn’t work, even after I uploaded the file to my ionic viewer on my phone.

Any ideas? Thanks!

Try to import ionic template app and build it

Hey @amandalp,

I think, you injected the code at the wrong place, make sure to inject it in the app.run() instead of the config().

Hi guys, I wrote a whole tutorial for you, find it here.

If you need more information feel free to ask, I’m always here.

I wrote it from the Android perspective. I tested everything on a real device and code us reusable.

@Gajotres I want to implement it ! But i have a doubt !

How the sms is sent to the the user ? via internet or user’s network connection ? Does it charge the user for sending the sms ?

I just want to send the otp on the user’s phone itself for verifying the number ! or is thr any better way to do this ?

Thanks !

@Sumeet123 SMS is sent via a network connection. Technically nothing will change, only difference, you’ll use your own app to send an SMS.

so it will charge the user right ? like in india suppose a telecom service charges 1 rupee per sms !
Since its using a telecom service !

yup…it will…it is just another way of sending sms …as soon as the sms is sent the charges apply

@pointdeveloper.com thanks for clearing the confusion ! please suggest some different way to cheive this which wont charge the user ! Thanks again

for anybody looking for a step by step tutorial on how to use the SMS plugin in a real application here’s a tutorial on how to create an application for buying public transport tickets via SMS: http://www.coding-dude.com/wp/mobile-apps/ionic-app-tutorial-create-a-mobile-app-for-purchasing-public-transport-tickets-via-sms/

Here’s an example in Ionic 2.

can i do the same on ios without open any app ?

Hi jimibi

First of all, thanks for your precise explanation.

I need to implement a ā€œPanic Buttonā€ on a Cordova/Ionic app. The user creates up to five contacts (name, mobile number) in the app. These contacts should receive a default SMS message when the user presses the panic button.

I was told that this cannot be done because Android and IOS directives disallow an app to send this kind of messages, so after the app is built and installed, this wouldn’t work.

Is that right?