How to detect browser and mobileweb platform using Ionic 4 because when I tried with below code in desktop browser it is not falling in ‘core’ condition.
<
In case anyone is still struggling with this on ionic4/cordova, I solved it using
import {Device} from '@ionic-native/device/ngx'
Just add it into your app.modules and run this.device.platform wherever you need to find out, to give an idea, the output on web and apk from this simple code
console.log(this.platform.platforms());
console.log(this.device.platform);
is this:
Running on web (desktop and mobile)
["android", "phablet", "cordova", "mobile", "hybrid"]
browser
Running android local (apk)
["android", "cordova", "desktop", "hybrid"]
Android
Now I can correctly use the plugins for browser or mobile correctly, in my case is image loading and cropping.
A full explanation can be found at https://www.damirscorner.com/blog/posts/20171124-DetectingWhereIonicAppIsRunning.html