How to detect if I am in browser (local development) in Ionic 2

前端 未结 7 1239
太阳男子
太阳男子 2020-12-03 03:00

I want to make sure to launch inappbrowser only if I am on devices (iOs, Android...), but if I am in browser (local development mode or just a Web App with gulp build), I wa

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-03 03:28

    Base on hhung, because core only detect if you are using a windows browser opening the application, but if you are using chrome mobile emulation, core will return false, but mobileweb will return true. Therefore you should use the following:

    if(this.platform.is('core') || this.platform.is('mobileweb')) {
      this.isApp = false;
    } else {
      this.isApp = true;
    }
    

提交回复
热议问题