[英]"Error: Uncaught (in promise): TypeError: Object(...) is not a function" using UniqueDeviceID
I am developing a project on ionic v3.我正在开发一个关于 ionic v3 的项目。
I want to get a unique device id in my application.我想在我的应用程序中获得一个唯一的设备 ID。
I followed the instructions at https://ionicframework.com/docs/native/unique-device-id/我按照https://ionicframework.com/docs/native/unique-device-id/ 上的说明进行操作
ts file: .ts 文件:
import { UniqueDeviceID } from '@ionic-native/unique-device-id/ngx';
constructor(private uniqueDeviceID: UniqueDeviceID) { }
login(){
this.uniqueDeviceID.get()
.then((uuid: any) => console.log(uuid))
.catch((error: any) => console.log(error));
}
In app.module.ts :在 app.module.ts 中:
import { UniqueDeviceID } from '@ionic-native/unique-device-id/ngx';
providers: [
StatusBar,
SplashScreen,
UniqueDeviceID,
{ provide: ErrorHandler, useClass: IonicErrorHandler },
AuthServiceProvider
]
When I am running it error occur:当我运行它时发生错误:
Error: Uncaught (in promise): TypeError: Object(...) is not a function
错误:未捕获(承诺):TypeError:Object(...) 不是函数
TypeError: Object(...) is not a function类型错误:Object(...) 不是函数
package.json包.json
{
"name": "sujagSindhiSamiti",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"start": "ionic-app-scripts serve",
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint"
},
"dependencies": {
"@angular/animations": "5.2.11",
"@angular/common": "5.2.11",
"@angular/compiler": "5.2.11",
"@angular/compiler-cli": "5.2.11",
"@angular/core": "5.2.11",
"@angular/forms": "5.2.11",
"@angular/platform-browser": "5.2.11",
"@angular/platform-browser-dynamic": "5.2.11",
"@ionic-native/core": "4.20.0",
"@ionic-native/device": "^5.19.1",
"@ionic-native/splash-screen": "4.20.0",
"@ionic-native/status-bar": "4.20.0",
"@ionic-native/unique-device-id": "^5.19.1",
"@ionic/storage": "2.2.0",
"cordova-android": "8.1.0",
"cordova-plugin-uniquedeviceid": "1.3.2",
"ionic-angular": "3.9.9",
"ionicons": "3.0.0",
"rxjs": "5.5.11",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.29"
},
"devDependencies": {
"@ionic/app-scripts": "3.2.4",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-ionic-webview": "^4.1.3",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"typescript": "2.6.2"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
},
"cordova-plugin-ionic-keyboard": {},
"cordova-plugin-uniquedeviceid": {}
},
"platforms": [
"android"
]
}
}
I see that you're using Ionic v3.9.9 so you can't use Ionic Native 5, because it requires Ionic v4.我看到您使用的是 Ionic v3.9.9,因此您不能使用 Ionic Native 5,因为它需要 Ionic v4。
Update the @ionic-native/* dependencies in your package.json to "4.20.0" and run npm install.将 package.json 中的 @ionic-native/* 依赖项更新为“4.20.0”并运行 npm install。 That should fix all the problems.
那应该可以解决所有问题。
Use Ionic Device Plugin for getting UUID.使用 Ionic Device Plugin 获取 UUID。
https://ionicframework.com/docs/native/device https://ionicframework.com/docs/native/device
This plugin also provides following facilities.该插件还提供以下功能。
model, platform, uuid, version, manufacturer, serial, isVirtual型号、平台、uuid、版本、制造商、序列号、isVirtual
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.