Skip to main content

Uid

Get unique identifiers: UUID, IMEI, IMSI, ICCID and MAC.

https://github.com/lionelhe/cordova-plugin-uid

Stuck on a Cordova issue?

Don't waste precious time on plugin issues.

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic’s experts offer premium advisory services for both community plugins and premier plugins.

Installation#

$ npm install cordova-plugin-uid
$ npm install @ionic-native/uid
$ ionic cap sync

Supported Platforms#

  • Android

Usage#

React#

Learn more about using Ionic Native components in React

Angular#

import { Uid } from '@ionic-native/uid/ngx';
import { AndroidPermissions } from '@ionic-native/android-permissions/ngx';
constructor(private uid: Uid, private androidPermissions: AndroidPermissions) { }
async getImei() {
const { hasPermission } = await this.androidPermissions.checkPermission(
this.androidPermissions.PERMISSION.READ_PHONE_STATE
);
if (!hasPermission) {
const result = await this.androidPermissions.requestPermission(
this.androidPermissions.PERMISSION.READ_PHONE_STATE
);
if (!result.hasPermission) {
throw new Error('Permissions required');
}
// ok, a user gave us permission, we can get him identifiers after restart app
return;
}
return this.uid.IMEI
}