How to detect platform using Ionic 4

前端 未结 8 1030
慢半拍i
慢半拍i 2021-02-09 08:24

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.

<
8条回答
  •  闹比i
    闹比i (楼主)
    2021-02-09 09:06

    The following link may help you:
    https://forum.ionicframework.com/t/how-to-determine-if-browser-or-app/89149/16

    or you can use the following method:

    public isDesktop() {
        let platforms = this.plt.platforms();
        if(platforms[0] == "core" || platforms[0] == "mobileweb") {
            return true;
        } else {
            return false;
        }
    }
    

提交回复
热议问题