I am using the following plugin for Cordova with Android:
$ cordova plugin add cordova-sms-plugin
I want to open default sms app in mobile using cordova app. I need to open sms app with mobile number and text after click button in cordova. Is this possible?
Here is my code:-
in html:-
<input id="numberTxt" placeholder="Enter mobile number" value="" type="tel" />
<textarea id="messageTxt" placeholder="Enter message"></textarea>
<input type="button" onclick="app.sendSms()" value="Send SMS" />
In app.js:-
var app = {
sendSms: function() {
var number = document.getElementById('numberTxt').value.toString(); /* iOS: ensure number is actually a string */
var message = document.getElementById('messageTxt').value;
console.log("number=" + number + ", message= " + message);
//CONFIGURATION
var options = {
replaceLineBreaks: false, // true to replace \n by a new line, false by default
android: {
intent: 'INTENT' // send SMS with the native android SMS messaging
//intent: '' // send SMS without opening any other app, require : android.permission.SEND_SMS and android.permission.READ_PHONE_STATE
}
};
var success = function () { alert('Message sent successfully'); };
var error = function (e) { alert('Message Failed:' + e); };
sms.send(number, message, options, success, error);
}
};