ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
51.07k stars 13.51k forks source link

platform.is('ios') return false on ios when deployed as app #14646

Closed rdndnl closed 6 years ago

rdndnl commented 6 years ago

Bug Report

Ionic Info Run ionic info from a terminal/cmd prompt and paste the output below.

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.9
    Cordova Platforms  : android 7.0.0 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    ios-deploy        : 1.9.2
    Node              : v8.11.2
    npm               : 5.6.0
    OS                : macOS High Sierra
    Xcode             : Xcode 9.4 Build version 9F1027a

Environment Variables:

    ANDROID_HOME : /opt/mobile/android/android-sdk-macosx

Misc:

    backend : pro

Describe the Bug platform.is('ios') return false on ios when deployed as app while return true when running inside Ionic DevApp. Creating a new App cannot reproduce this behaviour, the bug exists on my current app with several ionic-native plugins.

Steps to Reproduce Steps to reproduce the behavior:

  1. create an App
  2. put the following code in the MyApp constructor
  3. deploy on different platforms
  4. collect results:

    On Chrome:

    • platform: mobile: true
    • platform: ios: true
    • platform: iphone: true
    • platform: mobileweb: true

On an Android phone:

On an iOS - iPhone phone:

On Ionic DevApp (android)

On Ionic DevApp (ios - iphone)

Related Code

export class MyApp {
  rootPage: any = HomePage;

  constructor(platform: Platform,
              statusBar: StatusBar,
              splashScreen: SplashScreen) {

    platform.ready().then((source) => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();

      this.printPlatformList(platform);
    });
  }

  /**
   On Chrome:
   platform: mobile: true
   platform: ios: true
   platform: iphone: true
   platform: mobileweb: true

   On an Android phone:
   platform: cordova: true
   platform: mobile: true
   platform: android: true

   On an iOS - iPhone phone:
   platform: cordova: true
   platform: core: true

   On Ionic DevApp (android)
   platform: cordova: true
   platform: mobile: true
   platform: android: true

   On Ionic DevApp (ios - iphone)
   platform: cordova: true
   platform: mobile: true
   platform: ios: true
   platform: iphone: true
   */
  private printPlatformList(platform: Platform) {
    let platformList: string[] = platform.platforms();
    for (let i = 0; i < platformList.length; i++) {
      console.log('platform: ' + platformList[i] + ': ' + platform.is(platformList[i]));
    }
  }
}

Expected Behavior

platform.is('ios') === true when deployed on all iOS related platforms

Additional Context none

brandyscarney commented 6 years ago

Thank you for the issue! I am going to close this issue and merge it into #15165 to keep all platform issues in one.

ionitron-bot[bot] commented 6 years ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.