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)
            };
  • 相关阅读:
    文件I/O(二)
    linux学习之文件I/O篇(一)
    静态库和共享库
    vim-ide
    CentOS6 vsftpd 安装及优化方法
    Redmine2.5+CentOS6+Apache2
    分享一个TP5实现Create()方法的心得
    Windows证书的生成导出以及使用证书验证文件是否被修改
    如何设置程序UAC控制
    关于C#的可变长参数
  • 原文地址:https://www.cnblogs.com/xiaolei1004/p/angular_plugin_sms.html
Copyright © 2011-2022 走看看