@piotrde (Piotrde) posted a new topic, subject "Accessing external cordova plugin". It read:

   Hello,
    
    For few days I'm struggling with adding cordova plugins to my Ionic2 application. I tried several plugins and I always get the same error. Having the plugin added to my project (I used `ionic plugin add` command) with a clobbers content like below:
    [code] 
        <js-module src="plugin/www/pushmote.js" name="Pushmote">
            <clobbers target="Pushmote" />
        </js-module>
        
    [/code]
    
    my understanding is that I should be able to use that plugin just with `window.Pushmote`:
    [code] 
        import {Page} from 'ionic-angular';
        
        @Page({
          templateUrl: 'build/pages/page3/page3.html'
        })
        export class Page3 {
          constructor() {
            window.Pushmote.startWithApplicationId(...);
          }
        }
        
    [/code]
    
    Is that correct?
    
    Unfortunately, it doesn't work:
    
    > Error TS2339: Property ‘Pushmote' does not exist on type ‘Window'.
    
    This is not only about Pushmote plugin - it's just a next random plugin I've tried to incorporate into my project with no success. I'm still getting exactly the same error. What am I doing wrong?
    
    I've read this thread: Ionic 2 and custom plugin and looks that theoretically I'm doing everything correctly, so what is wrong?

So @rapropos (Robert Coie) replied

    Don't fall in love with this technique, because it subverts TypeScript's typing system, but when you have badly behaving modules that pollute the global namespace like this, the simplest way to handle it is:
    [code] 
        (<any>window).Pushmote.startWithApplicationId(...);
        
    [/code]

After which, @piotrde (Piotrde) added

    So what's the ideal way for plugin to register itself? I've looked at the source code of several plugins and all of them do  
    `module.exports = mymodule`  
    and some of them do additionally  
    `window.mymodule = ...`

@rapropos (Robert Coie) replied

    You can check out the ionic-native source code to see how other plugins have been made user-friendly.

Then @piotrde (Piotrde) said

    Thank you for help.
    
    Yet one question. With `(<any>window).Pushmote` I have everything working fine in android simulator. However, if I run `ionic serve`, `(<any>window).Pushmote` is `undefined`. I see it for every single plugin I try to access through `<any>window`. Is this expected behaviour? Is there any workaround?

To which @rapropos (Robert Coie) replied

    piotrde:
    
    > Is this expected behaviour?
    
    Yes.
    
    piotrde:
    
    > Is there any workaround?
    
    Depends on the plugin. Generally, no. Most plugins require a device environment.

After which, @piotrde (Piotrde) added

    Everything is clear now for me. Thanks!


{'source': 'discourse', 'url': 'https://forum.ionicframework.com/t/accessing-external-cordova-plugin/54817', 'title': 'Accessing external cordova plugin', 'views': 2542, 'has_accepted_answer': True, 'word_count': 376, 'like_count': 0, 'reply_count': 5, 'participant_count': 2, 'posts': 7, 'tags': '', 'author': '@piotrde (Piotrde)', 'participants': '@piotrde (Piotrde), @rapropos (Robert Coie)', 'image_url': [None], 'created_at': '2016-06-14T17:48:57.567Z', 'last_posted_at': '2016-06-29T13:23:26.593Z'}