Uid

Contents

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

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

联系我们?

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic's experts offer official maintenance, support, and integration help.

Contact Us Today!

Ionic 唯一标识Uid插件的安装(Installation)

ionic cordova plugin add cordova-plugin-uid npm install @ionic-native/uid
Ionic EE comes with fully supported and maintained plugins from the Ionic Team. Learn More or Contact Us
ionic enterprise register --key=YOURPRODUCTKEY npm install @ionic-enterprise/uid

Ionic 唯一标识Uid插件支持的平台(Supported Platforms)

  • Android

Ionic 唯一标识Uid插件的用法(Usage)

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
}