我需要在用户授予许可后立即检索设备IMEI。插件的示例代码说明,在用户授予许可后可以检索IMEI并重新启动应用程序(https://ionicframework.com/docs/native/uid)。如果未重新启动应用程序,则插件将始终返回空白。应用获得许可后,有什么方法可以立即获得IMEI?请帮忙。
这是我当前的代码:
async getImei(): Promise<string> {
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');
}
return this.getImei(); // i tried to call itself again but still no luck
}
return this.uid.IMEI
}