How to find device os and version in ionic

后端 未结 4 404
半阙折子戏
半阙折子戏 2021-01-24 09:27

I have worked on few tutorials and at last found something regarding this in ionic framework.....

They gave some codes that use ionic native and i did the same by embedd

4条回答
  •  不知归路
    2021-01-24 10:06

    In Ionic 3 you can use device this way,

    import { Device } from '@ionic-native/device';
    
    private platformType:any;
    private versionType:any;
    
    constructor(private device: Device) { 
    this.platformType = this.device.platform;
    this.versionType = this.device.version;
    }
    

    Now this can be used in the html file using data-binding ex:

    
      
       
         

    Platform Type: {{platformType}}

    OS Version: {{versionType}}

    Note: In the browser the variables will log null. The Device plugin function will only work on the native devices. You can test your device with

    ionic cordova run (android or ios) --device
    

提交回复
热议问题