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.
<
For detecting the web platform you should use Bowser . I have used this in ionic 4 for detecting browser platform i.e whether it is safari or chrome.
Step 1 : You need to install bowser in your project
npm install bowser@2.7.0 --save-exact
Step 2 : Then you need to import it in .ts page where you want to use it. let suppose home.ts
import Bowser from "bowser";
Step 3 : Then you need to write login to check browser platform inside a function in home.ts
checkBrowserPlatform() {
const browser = Bowser.getParser(window.navigator.userAgent);
const browserName = browser.getBrowserName();
console.log(browserName);
}
By calling checkBrowserPlatform() you can know the current browser name.