Detecting device platform on mobile if app is running in browser

Requirement - To detect mobile device if app is running as website in a web-browser of mobile device.

Using Device, I can detect whether app is running in browser or in a native app form.

But, is there a way to detect mobile device platform even if the app is running in a web-browser? I just need to know if it is a mobile device true or false.

I am using npm run build --prod command to generate required files for web hosting.
I have tried ionic cordova build/run browser. But I couldn’t make it work.

You can use the Platform class for this

Solution -

import { Platform } from 'ionic-angular';

export class ABCD{
    constructor(public platform: Platform) { }

    isMobileBrowser(){
        // is this web-browser on mobile device
        return this.platform.is('mobileweb');
    }
} 

2 Likes