wagng
wagng

Reputation: 711

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!

Upvotes: 5

Views: 6418

Answers (1)

Will.Harris
Will.Harris

Reputation: 4014

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);
}

Upvotes: 9

Related Questions