【问题标题】:Ionic Run time Error: Uncaught (in promise): cordova_not_available离子运行时错误:未捕获(承诺):cordova_not_available
【发布时间】:2018-08-26 23:51:48
【问题描述】:

我正在开发一个离子项目,该项目最近在一些更新后完美运行,它神奇地停止工作。 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;
        }
      });
    }

【问题讨论】:

  • 可以分享登录功能吗....
  • 我已经粘贴了登录功能的代码,我在this.push.hasPermission()这一行得到了错误
  • 这个功能是在真正的安卓设备上工作的......
  • 没有。它不适用于真实设备
  • 可以分享一下loginService的登录方法吗?

标签: android cordova ionic-framework ionic3


【解决方案1】:

Cordova 仅可在真实设备上使用,无需实时重新加载。 您可以通过以下方式检查您是否可以访问它:

if (window.hasOwnProperty("cordova")) {
 //plugins init that need cordova
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-05
    • 2017-10-04
    • 2021-10-02
    • 2020-03-17
    • 1970-01-01
    • 2019-08-11
    • 1970-01-01
    相关资源
    最近更新 更多