Using windows.plugins with Ionic 2 Typescript


#1

Can you use windows.plugins.xxx 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()


#2

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


#3

That seems to work thanks.


#4

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.


#5

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.