Using windows.plugins with Ionic 2 Typescript

Can you use in an ionic 2 Typescript app?

I am getting an error Property ‘plugins’ does not exist on type ‘Window’ with the OneSignal plugin window.plugins.OneSignal.init()

Try window['plugins'].OneSignal.init()


That seems to work thanks.

Just a bit more on this. All this means is that typescript is giving you a warning. It’s not breaking your build or anything, it’s just letting you know that it doesn’t know about this code.

What you can do is see if the plugin is part of ionic-native, or see if there are any typings for the cordova plugin.

The plugin is not part of ionic native.

The problem with the errors is being sure which are real errors that need dealing with and which can very safely be ignored. I feel more comfortable getting rid of as many error messages as possible.

1 Like