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.
<
Currently Ionic 4 has support for platform detection. The following code works for me.
import { Platform } from '@ionic/angular';
...
constructor(private platform: Platform) {}
...
ngOnInit() {
this.platform.ready().then(() => {
if (this.platform.is('android')) {
console.log('android');
} else if (this.platform.is('ios')) {
console.log('ios');
} else {
//fallback to browser APIs or
console.log('The platform is not supported');
}
}}