0

我按照以下说明操作:https ://ionicframework.com/docs/native/unique-device-id/并version 5.0.0已安装

ts文件

import { UniqueDeviceID } from '@ionic-native/unique-device-id/ngx';   

constructor(private uniqueDeviceID: UniqueDeviceID) { }

this.uniqueDeviceID.get()
        .then((uuid: any) => console.log(uuid))
        .catch((error: any) => console.log(error));   

app.module.ts 中

import { UniqueDeviceID } from '@ionic-native/unique-device-id/ngx';

providers: [
    StatusBar,
    UniqueDeviceID,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]     

错误

在此处输入图像描述

4

1 回答 1

0

这是一个机会。App.module.ts 中的初始化

    providers: [
     StatusBar,
     SplashScreen,
     {provide: ErrorHandler, useClass: IonicErrorHandler},
     UniqueDeviceID
   ]  

也在 App.component.ts 的 ngOnInit 中运行它

    this.uniqueDeviceID.get()
     .then((uuid: any) => console.log(uuid))
     .catch((error: any) => console.log(error));
于 2019-12-27T11:00:05.893 回答