Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get device id in Ionic 2 using TypeScript

I am trying to get device id in ionic2 using typescript.

I installed cordova-plugin-device

And my code is....

platform.ready().then(() => {
   console.log(device.cordova);
}

But this is not working.

When I launch the app on device, there is no any log.

Please help me.

Thank you!

like image 656
wagng Avatar asked May 03 '16 07:05

wagng


1 Answers

It looks like this is in the Ionic 2 docs. What you need to do is import the Device class from ionic-native and call the uuid property of the device object.

For example

import {Device} from 'ionic-native';

platform.ready().then(() => {
   console.log(Device.device.uuid);
}
like image 176
Will.Harris Avatar answered Nov 15 '22 03:11

Will.Harris