TheShalit TheShalit - 1 year ago 105
Javascript Question

Check if ionic app is in dev serve mode(browser)

I use

ionic serve
to run my app on localhost.

how can I know when I'm in browser and not in android?

I tried:

navigator.platform // MacIntel
navigator.platforms // undefined'BROWSER') // false
navigator.userAgent // ...iPhone... => i'm in chrome device mode

Thank you!

Answer Source

There's probably more than one way to do it, but a simple one is that cordova will only be defined on Android/iOS so you could do

if (window.cordova) {
  // running on device/emulator
} else {
  // running in dev mode
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download