I am running a ionic project on browser
script
"browser": "ionic-app-scripts serve --sourceMap source-map --iscordovaserve --wwwDir platforms/browser/www/ --buildDir platforms/browser/www/build"
and running npm run browser
I am trying this piece of code in app.component.ts
if (this.platform.is('ios') || this.platform.is('android') || this.platform.is('mobile'))
//execute certain function only on mobile
Problem
this.platform.is('mobile')
and this.platform.is('android')
is returning true
to me in case of browser which is weird behaviour.
So , how to obtain the condition so that on browser i want to disable certain feature and why is the above code not working as expected. Thanks.
There are two approaches i got.
As suggested By Sergey
let isWebApp = this.platform.url().startsWith('http');
Found on the Ionic Forum
!document.URL.startsWith('http');
These are mainly used for development as development process is faster is in browser as changes are reflected instantly.