zoukankan      html  css  js  c++  java
  • 实现点击可以跳转到手机自带的短信应用界面来收发短信

    首先用到的插件名字:cordova-sms-plugin

    • 在Cordova环境下安装cordova-sms-plugin插件:
    1. 第一种方式:cordova plugin add https://github.com/cordova-sms/cordova-sms-plugin.git
    2. 第二种方式:ionic plugin add cordova-sms-plugin

    这2种方式哪一种都可以。

    • app.js中注入ngCordova           controller.js中注入$cordovaSms
    var App = angular.module('starter', ['ionic', 'ngCordova','LocalStorageModule','ionic-datepicker','ngImgCrop','gdi2290.md5'])
      .config( ['$compileProvider', function( $compileProvider ) {
        $compileProvider.aHrefSanitizationWhitelist(/^s*(https?|ftp|mailto|tel|file|sms):/);
      }
    ])

    需要发短信的controller中引入$cordovaSms

    App.controller('MemberDataController', ['MemberDataService','$scope','$stateParams','$state','Storage','$cordovaSms','warningForm',
        function (MemberDataService,$scope,$stateParams,$state,Storage,$cordovaSms,warningForm) {
    • 调用方法,发送短信
            //打开发送短信的popup
            $scope.openSendMessage = function (phonenumber) {
                console.log("发送消息:" + phonenumber);
                var options = {
                    replaceLineBreaks: false, // true to replace 
     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
                    }
                };
                sms.send(phonenumber, '内容', options)
            };
  • 相关阅读:
    Membership角色与权限管理
    Virtual PC 2007 下载地址
    Support Web Application Projects
    CSS使用高级技巧20则
    apache和IIS共用80端口
    Dreamweaver扩展(插件)使用
    CSS横向菜单下拉显示子菜单
    openPNE创建项目
    基础AJAX
    连接数据库
  • 原文地址:https://www.cnblogs.com/xiaolei1004/p/angular_plugin_sms.html
Copyright © 2011-2022 走看看