this is ngcrdova sms plug-in using ionic framwork i put this code in app.js but
ID: 3583822 • Letter: T
Question
this is ngcrdova sms plug-in using ionic framwork
i put this code in app.js
but i want to know what to write in index.html file to conncet both of them ?? and get the proper output :(
Easily send SMS natively in iOS or Android SMS app cordova plugin add https:// sms cordova sms-plugin. git github.com/cordova Example module. controller ThisCtrl function (scordovasms) document addEventListener ("deviceready", function f $cordovasms send phonenumber SMS content options then (fi unction Success SMS was sent function (error) h, An error occurredExplanation / Answer
index.html
<!DOCTYPE html>
<html>
<head>
<script src="cordova.js"></script>
<script src="app.js"></script>
</head>
<body>
<header">
<h1 class="title">Send SMS</h1>
</header>
<div class="content">
<div class="content-padded">
<form>
<input type="text" id="phonenumber" placeholder="Phone Number"><br/>
<textarea id="smscontent" ></textarea>
<input type="button" id="sendMsg" value="Send Message">
</form>
</div>
</div>
</body>
</html>
Above HTML page contains a text input field to enter the phone number and a text area to input the SMS content. Now call the SMS sending module to send the message once user clicks on send button on the HTML page.
app.js
document.addEventListener("deviceready", init, false);
function init() {
document.querySelector("#sendMsg").addEventListener("touchend", function() {
var phonenumber = document.querySelector("#phonenumber").value;
var textcontent = document.querySelector("#textcontent").value;
if(number === '' || message === '') //if number or sms content is blank
return;
var msg = {
phoneNumber:phonenumber,
Message:textcontent
};
sms.sendMessage(msg, function(message) {
navigator.notification.alert("The Message has been successfully sent to " + number);
}, function(error) {
navigator.notification.alert('Unable to send message due to the error: ' + error.message,);
});
}, false);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.