码迷,mamicode.com
首页 > 其他好文 > 详细

cordova 短信插件

时间:2016-07-05 14:01:10      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:

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

 

https://github.com/cordova-sms/cordova-sms-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

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 短信插件

标签:

原文地址:http://www.cnblogs.com/zhangchengyuan/p/5643252.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!