简体   繁体   English

结合使用Cordova插件和IONIC而非ionic-native

[英]Using Cordova plugin with IONIC not ionic-native

I am trying to use local notifications cordova plugin from here . 我正在尝试从此处使用本地通知cordova插件。

I don't want to use the ionic-native solution from here because it does not implement all features I need. 我不想从这里开始使用离子本机解决方案,因为它不能实现我需要的所有功能。

I have installed the cordova plugin like so cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications 我已经像那样安装了cordova插件,所以cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications

Then I try to use after platform.ready like so.. 然后我尝试在platform.ready之后使用。

   this.plt.ready().then(()=> {
         (<any>window).plugins.notification.local.schedule({
         id: 1,
         title: "Fitness App",
         text: "Timer done",
         priority: 1,
         at: Date.now()
       });
   });

I have tested this on a real device and in the browser (although I know it won't work in the browser). 我已经在真实的设备和浏览器中对此进行了测试(尽管我知道它无法在浏览器中运行)。 In the browser it says that notification is not defined. 在浏览器中,它表示未定义通知。

My question is how can I properly import the plugin to use with ionic. 我的问题是如何正确导入要与ionic一起使用的插件。

I found the solution. 我找到了解决方案。 Using the following code allowed me to use the cordova plugin with IONIC. 使用以下代码使我可以将cordova插件与IONIC一起使用。 Without having to use the ionic-native solution. 无需使用离子本征溶液。

declare var cordova;

(<any>cordova).plugins.notification.local.schedule({

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

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