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)
            };
  • 相关阅读:
    学习Vue.js
    Xmind思维导图
    Webpack 入门教程
    Vscode 使用介绍
    jdk,jre下载安装
    Java JDK下载
    FileZilla FTP下载
    notepad++下载
    windows环境搭建Vue开发环境
    SecureCRTPortable的安装和使用(图文详解)
  • 原文地址:https://www.cnblogs.com/xiaolei1004/p/angular_plugin_sms.html
Copyright © 2011-2022 走看看