简体   繁体   English

如何在离子应用程序中使用此SMS插件?

[英]How to use this SMS plugin in my ionic application?

I am trying to use this sms plugin - https://github.com/Ivanezko/Phonegap-SMS in my ionic android application. 我正在尝试在我的离子android应用程序中使用此sms插件-https: //github.com/Ivanezko/Phonegap-SMS I am following the Readme documentation to install the plugin. 我正在按照自述文件中的说明安装插件。 In the second step author asked to do - 在第二步中,作者要求做-

Require the plugin module

var smsplugin = cordova.require("info.asankan.phonegap.smsplugin.smsplugin"); 

What this statement means and where should I include this code to make use of this plugin? 该语句意味着什么,我应该在哪里包括此代码以使用此插件?

I tried to do this in my controller file and its giving error cordova is not defined. 我试图在我的控制器文件中执行此操作,并且未定义错误Cordova。

I tried debugging a little more in an emulator and the error given in the require statement is - module info.asankan.phonegap.smsplugin.smsplugin is not found. 我尝试在模拟器中进行更多调试,并且require语句中给出的错误是- 找不到模块info.asankan.phonegap.smsplugin.smsplugin。

First solution: 1. check that this plugin is wrapped by http://ngcordova.com/ . 第一个解决方案:1.检查此插件是否由http://ngcordova.com/包装。

Second solution: 2. write wrapper = angular factory: 第二种解决方案:2.写包装=角度工厂:

.factory('factoryname', ['$q', '$window','$state', function ($q,$window, $state) {
 return {
  function1: function () {
        var q = $q.defer();
        if (!$window.cordova) {
          q.reject('Not supported without cordova.js');
        } else {
          secrettext.function1();
         return q.promise;
      },

3th solutions: add ['$window'] dependency to module you want use plugin. 第三个解决方案:向要使用插件的模块添加['$ window']依赖项。 and use secrettext.function1(); 并使用secrettext.function1();

*sectretext its clobbers from plugin xml *从插件XML中加密文本

4 th solutions copy and paste this js code into you angular code on top of it and use function1(); 第四个解决方案将此js代码复制并粘贴到它上面的角度代码中,并使用function1();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM