Cordova plugins not working with ionic

≡放荡痞女 提交于 2019-12-01 14:24:35

问题


I have an Ionic app built with Angular.

I am using is Calendar plugin: https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin

I want to create events through the plugin and save them to the local device's calendar.

I have added the plugin though:

cordova plugin add https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin.git

And I try to use it in my controller:

 ionic.Platform.ready(function(){onError);
    window.plugins.calendar.createEvent(title, location, notes, start, end, onSuccess, onError);
 });

In the browser it says window.plugins is undefined and on the device the error is 'undefined' is not an object (evaluating 'window.plugins.calendar')

I have searched high and low for this, I cant seem to find a solution that works.

Any idea how to use a Cordova plugin with Ionic?


回答1:


The answer was to add

<script src="cordova.js"></script>

And rebuild the Platforms

If still issue not resolved, remove and add the platforms




回答2:


Cordova plugins only runs on emulators or real devices.

To test a Cordova app with the browser take a look also to Ripple Emulator (Chrome plugin), but I prefer to test on real devices.

Cheers!



来源:https://stackoverflow.com/questions/25684371/cordova-plugins-not-working-with-ionic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!