详情连接地址:http://www.ncloud.hk/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/cordova-1-cordovasms/android
这是调用手机发送短信的插件,由于在作项目的时候有这个需求找了一下看到这个,在这里简单介绍一下,使用以前有必定的ionic基础和开发项目的经验。git
一、首先须要有一个简单的项目,而后在命令行输入添加插件的命令:github
cordova plugin add https://github.com/cordova-sms/cordova-sms-plugin.git |
二、在HTML中的代码以下:app
<input id="numberTxt" placeholder="Enter mobile number" value="" type="tel" /> <textarea id="messageTxt" placeholder="Enter message"></textarea> <input type="button" ng-click="sendSms()" value="Send SMS" />
三、在JS中的代码以下,这个代码写在相应的控制器里而且依赖‘$cordovaSms’,记得在app.js里依赖‘ngCordova’,:ionic
$scope.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); }
这样子简单的发送短信的功能就实现了,可是本人发现它不可以知足群发短信的需求,因此若是想作群发消息的功能就得另寻他法了!spa