Can you use window.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()
You could fix this by referencing plugins as an array property instead of object.
var OneSignalClient = window['plugins'].OneSignal.init()
Typescript doesn't check if array properties are defined on initial build so it safely passes inspection.
P.S. If you're not using Ionic but some other framework ( Angular 2 ), you won't have a plugins object in your window object, so you'll have to load OneSignal like this:
let OneSignalClient = window['OneSignal'] || [];
Hope this helps.
You can call OneSignal directly without having to go through window. It looks like their documentation is a bit out of date.
OneSignal.init()
should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With