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
ionic.Platform.is('BROWSER') // false
navigator.userAgent // ...iPhone... => i'm in chrome device mode
Thank you!
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
}
use
if(ionic.Platform.isWebView()){
console.log('i am in a browser webview!');
}
or
console.log(ionic.Platform.platform());
That will tell you what platform you are on. Webview or android or ios or whatever.