Cordova SMS Plugin

Source: Internet
Author: User



Https://www.npmjs.com/package/cordova-sms-plugin






Https://github.com/cordova-sms/cordova-sms-plugin


Installing the Plugin


Using the Cordova CLI and NPM, run:


cordova plugin add cordova-sms-plugin


It is also possible to install via repo URL directly (unstable), run:


cordova plugin add https://github.com/cordova-sms/cordova-sms-plugin.git
Using the Plugin


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" />


Javascript


var app = {
    sendSms: function() {
        var number = document.getElementById(‘numberTxt‘).value;
        var message = document.getElementById(‘messageTxt‘).value;
        alert(number);
        alert(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 open any other app
            }
        };

        var success = function () { alert(‘Message sent successfully‘); };
        var error = function (e) { alert(‘Message Failed:‘ + e); };
        sms.send(number, message, options, success, error);
    }
};


Cordova SMS Plugin


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.