Ionic 4 this.platform.is returning wrong value

Started a new Ionic 4 sidemenu app and added Platform. Code below, on Safari and Chrome it returns Android for Platform and Versions. Any suggestions?? BTW, when running in iOS simulator the correct values are returned.

import { Component } from '@angular/core';
import { Platform } from "@ionic/angular";
import { Device } from '@ionic-native/device/ngx';

@Component({
  selector: 'app-page-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})
export class HomePage {
  myDevice: string;
  myHeight: any;
  myWidth: any;
  myPlatforms: any;
  myVersions: any;
  constructor(public platform: Platform, private device: Device)
  {

    platform.ready().then(() => {
      this.onDeviceReady();
    });
  }

  onDeviceReady() {

    if(this.platform.is('ios')){
      this.myDevice = 'ios';
    }
    if(this.platform.is('android')){
      this.myDevice = 'android';
    }
    if(this.platform.is('mobileweb')){
      this.myDevice = 'web';
    }
    if(this.platform.is('core')){
      this.myDevice = 'web';
    }
    this.myHeight = this.platform.height();
    this.myWidth = this.platform.width();
    this.myPlatforms = this.platform.platforms();
    this.myVersions = JSON.stringify(this.platform.versions());
    console.log('Device UUID is: ' + this.device.uuid);
    console.log('Device platform is: ' + this.device.platform);
    console.log('Device verision is: ' + this.device.version);

  }
}

Results:
46%20AM

My Ionic Info:

Ionic:

   ionic (Ionic CLI)          : 4.0.1 (/usr/local/lib/node_modules/ionic)
   Ionic Framework            : @ionic/angular 4.0.0-beta.0
   @angular-devkit/core       : 0.7.0-rc.3
   @angular-devkit/schematics : 0.7.0-rc.3
   @angular/cli               : 6.0.8
   @ionic/ng-toolkit          : 1.0.0
   @ionic/schematics-angular  : 1.0.0

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : ios 4.5.5

System:

   ios-deploy : 1.9.2
   ios-sim    : 5.0.13
   NodeJS     : v9.5.0 (/usr/local/bin/node)
   npm        : 6.2.0
   OS         : macOS High Sierra
   Xcode      : Xcode 9.4.1 Build version 9F2000

Environment:

   ANDROID_HOME : not set

I’ve already posted this bug on Github. They’ve also messed the android platform detection.

onic-4 Platform specific value

goto- node_modules@ionic\angular\dist\providers\platform.d.ts

Platform Name | Description |

 * | android         | on a device running Android.       |
 * | cordova         | on a device running Cordova.       |
 * | ios             | on a device running iOS.           |
 * | ipad            | on an iPad device.                 |
 * | iphone          | on an iPhone device.               |
 * | phablet         | on a phablet device.               |
 * | tablet          | on a tablet device.                |
 * | electron        | in Electron on a desktop device.   |
 * | pwa             | as a PWA app.   |
 * | mobile          | on a mobile device.                |
 * | desktop         | on a desktop device.               |
 * | hybrid          | is a cordova or capacitor app.     |

Yes, same issue here, after run once

ionic serve --devapp

quitted the serve process, and then launched:

ionic serve

served

(3) ["android", "mobile", "mobileweb"]

in broswer.


Moreover, all github related issues are now closed without solutions, patch or upgrades.


Now trying to upgrade ionic from 5.0 to 5.2 latest and see it would help.

I’m now using ionic 5.4.3 and it still not working

I use Ghrome with the developer toolbar to test my mobile view, but platform “core” is still not available

If you Enabled Toggle device toolbar from browser, It’ll return mobile. and if it is disabled then return desktop.
be sure to refresh the page(f5) after changing the state of that.