Ionic系列——发送短信

一、需求描述

    最近作的项目须要有提醒用户的功能,就是能够调用手机的发送短信功能android

二、准备

     ①、添加插件$cordovaSMSgit

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

    ②、在controller中添加依赖github

三、代码实现

//发短信
$scope.sendMessage=function(){
    //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
        }
    };
    $cordovaSms
        .send('18654332789', 'SMS content',options)
        .then(function() {
            // Success! SMS was sent
            CommonJs.AlertPopup("发送短信成功");
        }, function(error) {
            // An error occurred
        });
};

四、注意点

    看来不少东西都须要去官网看原代码和文档,ng-cordova的文档也不全,没有介绍option怎么配置,能够从github上找一些开源的其余插件。怎么找其余的开源插件介绍一下

    https://github.com/cordova-sms/cordova-sms-plugin 官网地址和介绍。
app

相关文章
相关标签/搜索