我正在研究一个离子项目,该项目最近在一些更新后完美地工作,它神奇地停止工作。
ionic serve
命令在浏览器上成功运行,但是当我在移动设备上运行项目时,它始终显示错误uncaught (in promise): cordova_not_available
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
@ionic/app-scripts : 3.1.8
Cordova Platforms : android 7.0.0
Ionic Framework : ionic-angular 3.9.2
System:
Node : v8.9.4
npm : 5.6.0
OS : macOS High Sierra
请建议任何解决方案。谢谢。 这里是插件列表:
> cordova plugin ls
cordova-android-support-gradle-release 1.2.0 "cordova-android-support-gradle-release"
cordova-plugin-android-permissions 1.0.0 "Permissions"
cordova-plugin-badge 0.8.7 "Badge"
cordova-plugin-camera 4.0.2 "Camera"
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-device 2.0.1 "Device"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-file-opener2 2.0.19 "File Opener2"
cordova-plugin-file-transfer 1.7.1 "File Transfer"
cordova-plugin-filechooser 1.0.1 "File Chooser"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-inappbrowser 2.0.2 "InAppBrowser"
cordova-plugin-ionic-keyboard 2.0.5 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview"
cordova-plugin-local-notification 0.9.0-beta.2 "LocalNotification"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.1 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-plugin-x-socialsharing 5.3.2 "SocialSharing"
cordova.plugins.diagnostic 4.0.3 "Diagnostic"
es6-promise-plugin 4.2.2 "Promise"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-plugin-push 2.1.3 "PushPlugin"
这是发生此错误的文件代码
if (this.platform.is('android') || this.platform.is('ios')) {
this.CS.notifications();
this.push.hasPermission()
.then((res: any) => {
if (res.isEnabled) {
this.CS.pushObject.on('registration').subscribe((registration: any) => {
this.CS.device_id = registration.registrationId;
this.loginService.login(this.user).subscribe( (res) => {
if(this.loginService.isLoggedIn == true) {
}else{
this.show = true;
}
});
});
} else {
this.CS.alertMessage("error", "We do not have permission to send push notifications.")
}
});
}else{
this.loginService.login(this.user).subscribe( (res) => {
if(this.loginService.isLoggedIn == true) {
this.NavCtrl.setRoot(GroupsComponent);
/*this.CS.activeGroupId = 35;
this.CS.group_chat = true;
this.NavCtrl.push(TabsWrapperPage);*/
}else{
this.show = true;
}
});
}
答案 0 :(得分:0)
Cordova仅适用于真实设备且无需重新加载。 您可以通过以下方式检查是否可以访问它:
if (window.hasOwnProperty("cordova")) {
//plugins init that need cordova
}