1

With the following command I installed a cordova plugin on my ionic2 project:

cordova plugin add cordova-plugin-rfduino

This plugin is not available in the Ionic Native. How can I use the plugin in an ionic page? Can I export it somehow?

hopper
  • 4,230
  • 8
  • 36
  • 49

2 Answers2

0

When you install the plugin you can use it from the global window object, but the typescript will not understand what is rfduino object and its type, so you have to declare it to the declarations file which is located in src/declarations.d.ts, so you will be able to use it by just adding this line of code in that file

declare var rfduino: any;
Jamil
  • 889
  • 8
  • 10
0

I fixed it the following way:

0 - Install your plugin

1- npm install typings --global

2 - On typings/index.d.ts put the following code:

    interface Window {
       plugins: any;
    } 

3 - Then use the window the following way inside the page or component:

  constructor(platform: Platform) {
platform.ready().then(() => {


 var blabla = window['cordova_plugin_that_was_installed'].function();

   });
 }}
hopper
  • 4,230
  • 8
  • 36
  • 49