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

Ionic系列——发送短信

时间:2015-08-13 10:11:44      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:

1、需求描述

    最近做的项目需要有提醒用户的功能,就是可以调用手机的发送短信功能

2、准备

     ①、添加插件$cordovaSMS

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

    ②、在controller中添加依赖

3、代码实现

//发短信
$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
        });
};

4、注意点

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

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


Ionic系列——发送短信

标签:

原文地址:http://my.oschina.net/u/1416844/blog/491696

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