首页 文章

如何在离子4中使用非原生cordova插件

提问于
浏览
1

我试图在我的Ionic 4应用程序中使用此插件:https://github.com/IOCare/cordova-plugin-smartconfig

我使用 ionic cordova plugin add https://github.com/IOCare/cordova-plugin-smartconfig.git 安装了插件,它似乎被添加到项目中 . Cordova插件列表显示:cordova-plugin-smartconfig 1.0.4 "Cordova Smart Config"

I have tried:

declare var espSmartConfig: any; 并使用 espSmartConfig.startConfig()

declare var cordova: any; 并使用 cordova.plugins.espSmartConfig.startConfig()

declare var window: any; 并使用 window.espSmartConfig.startConfig()

..但一切都不明 . 我已经尝试在我的Android手机上使用Ionic DevApp,并在我的PC上使用chrome .

我确定我错过了一些明显的东西,但我无法弄清楚是什么 . 我发现的所有文档都指的是本机插件 .

2 回答

  • 0
    • 首先使用添加插件 .

    cordova插件添加https://github.com/IOCare/cordova-plugin-smartconfig.git

    • 然后在app.ts中

    声明var espSmartconfig;

    • 要启动配置,请使用此选项 .

    espSmartconfig.startConfig("ssid","00:00:00:00","password","NO",1,function(res){},function(error){console.log(error);});

    • 记得在完成后停止配置 .

    espSmartconfig.stopConfig(function(res){console.log(res);},function(error){console.log(error);});

  • 0

    正如你们中的一些人建议我尝试构建应用程序并在手机上运行它 . 工作就像一个魅力:

    declare var espSmartConfig: any;
    

    所以这里的问题只是我用来测试应用程序的工具 .

    谢谢大家的意见!

相关问题