首先执行命令
cordova plugin add https://github.com/cordova-sms/cordova-sms-plugin.git
安装不上可以选择执行
ionic plugin add cordova-sms-plugin
附件中有ng-cordova.js 下载,要在图中所示的cordova.js之前引用进去。
app.js中注入ngCordova controller.js中注入$cordovaSms
然后调用下面方法就可以咯!
$scope.sendMsg = function (mobilePhone) {
console.log("发送消息:" + mobilePhone);
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
}
};
$cordovaSms.send(mobilePhone, '内容', options)
}