Search code examples
cordovaarduinoionic2cordova-pluginsrfduino

Ionic 2 - How do I use a cordova plugin that is not available in ionic native


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?


Solution

  • 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();
    
       });
     }}