How to detect platform using Ionic 4

You can use Capacitor’s Device API:

import { Plugins } from '@capacitor/core';

const { Device } = Plugins;

const info = await Device.getInfo();
console.log(info);

It outputs platform:

{model: "Macintosh", platform: "web", appVersion: "", osVersion: "10.14.5", manufacturer: "Google Inc.", …}

1 Like

This works for me: https://stackoverflow.com/a/60306165/1077309

if your using capacitor, I found this way to be really cool and simple

import { Capacitor } from '@capacitor/core'

...

console.log(Capacitor.isNative) // --> false
console.log(Capacitor.platform) // --> "web"
console.log(Capacitor.getPlatform()) // --> "web"

this is on a Mac OSX testing (due to having the inapp purchase)

more info:

if Browser insect mode with device frame ios then platform.is(‘ios’) is triggering.
and platform.is(‘cordova’) not working in ionic 3.
any suggestion please.