[Common Plugin] Error cordova is not defined gets logged

Forge Component
Published on 2018-12-19 by OutSystems R&D
23 votes
Published on 2018-12-19 by OutSystems R&D

Invoking GetPlatform on a browser logs an error "cordova is not defined" unnecessarily, and then returns an empty value. This might pollute error logs if your developers use a browser to test the app, or if you're distributing using PWA.

To fix, simply include an IF checking if IsCordovaDefined:

I would also remove the error handlers in this module, which follow the Error Hiding anti-pattern, and could be hiding other issues, although I haven't detected anything else so far.

I'm attaching the module with my suggested changes.


This is super helpful having the same-ish issues with a PWA.