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
I used cordova-plugin-device to fetch uuid number and device model name. It fetches all possible information about the device. I believe, It will also serve your purpose. Inside onDeviceReady() function, you just assign the values to your convenient variables, like: var deviceOS = device.uuid; var deviceVersion = device.version; Hope It helps. Please let me know if it works. :)
Please see this link http://ionicframework.com/docs/api/utility/ionic.Platform/
angular.module('PlatformApp', ['ionic'])
.controller('PlatformCtrl', function($scope) {
ionic.Platform.ready(function(){
// will execute when device is ready, or immediately if the device is already ready.
});
var deviceInformation = ionic.Platform.device();
var isWebView = ionic.Platform.isWebView();
var isIPad = ionic.Platform.isIPad();
var isIOS = ionic.Platform.isIOS();
var isAndroid = ionic.Platform.isAndroid();
var isWindowsPhone = ionic.Platform.isWindowsPhone();
var currentPlatform = ionic.Platform.platform();
var currentPlatformVersion = ionic.Platform.version();
ionic.Platform.exitApp(); // stops the app
});
You can get the device os and version in ionic
import { Device } from '@ionic-native/device';
import { Platform } from 'ionic-angular';
constructor(private device: Device,public platform: Platform) {
console.log('Device UUID is: ' + this.device.uuid);
if (this.platform.is('ios')) {
// This will only print when on iOS
console.log('I am an iOS device!');
}
if (this.platform.is('android')) {
// This will only print when on Android
console.log('I am an android device!');
}
}
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:
<ion-grid>
<ion-row>
<ion-col>
<h1>Platform Type: {{platformType}}</h1>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<h1>OS Version: {{versionType}}</h1>
</ion-col>
</ion-row>
</ion-grid>
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