EddyVerbruggen / Insomnia-PhoneGap-Plugin

:sleepy: Prevent the screen of the mobile device from falling asleep

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: 'undefined' is not an object (evaluating 'window.plugins.insomnia')

kalepail opened this issue · comments

Hey, loving this little plugin, but ran into a bug when in development. It's working like a charm once you're on the phone but is throwing an error when building in development on a non phone server.

It's throwing the TypeError: 'undefined' is not an object (evaluating 'window.plugins.insomnia') I assume this has something to do with newer versions of Cordova not building out the JS or something. Any ideas for a fix or work around so I can get back to developing without having to comment this line out all the time?

Hi Tyler,

This is quite normal behaviour because plugins can't be used when not on a device or decent emulator.

The best thing to do is only calling the plugin when window.plugins !== undefined

Hope this makes sense,
Eddy