选择帐户后,Ionic 4 Firebase Auth signInWithRedirect()挂起

时间:2019-02-04 02:06:58

标签: javascript firebase ionic-framework firebase-authentication ionic4

我正在尝试使用Firebase的授权登录服务(特别是google)。我在这里使用一个简单的例子:

google() {
    const provider = new auth.GoogleAuthProvider()
    this.afAuth.auth.signInWithRedirect(provider).then(() => {
      this.afAuth.auth.getRedirectResult().then(result => {
        console.log('signed in', result);
      }).catch(error => {
        console.log('signin error', error);
      });
    });
  }

如果我使用ionic serve运行该应用程序并在浏览器中查看该应用程序,则可以正常运行。当我尝试在具有ionic cordova run android -prod -release的设备上运行该应用程序时(或者如果我通过Android商店将其作为Alpha版本发送出去),则会遇到以下问题

当我尝试使用该服务时,我被重定向到能够选择Google帐户的浏览器。我可以选择该帐户,然后将我重定向到一个空白页面,并显示此确认/警告框:

Firebase redirects to alert box

如果我要按“确定”,则会显示另一个警报框:

Second Redirect

在此按钮上按OK(确定)后,它进入空白屏幕,浏览器加载栏固定在75%并挂起。看来我无法重定向回自己的应用。

同样,该问题仅在设备上发生。我尝试使用signInWithPopup(针对Google的建议),但我得到的问题基本相同。我可以很好地使用电子邮件/密码组合。

有什么想法吗?下面是我的package.json,如果其中包含任何提示:

{
  "name": "[my app]",
  "version": "1.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "6.0.9",
    "@angular/core": "6.0.9",
    "@angular/fire": "^5.1.1",
    "@angular/forms": "6.0.9",
    "@angular/http": "6.0.9",
    "@angular/platform-browser": "6.0.9",
    "@angular/platform-browser-dynamic": "6.0.9",
    "@angular/router": "6.0.9",
    "@ionic-native/core": "5.0.0-beta.14",
    "@ionic-native/splash-screen": "5.0.0-beta.14",
    "@ionic-native/status-bar": "5.0.0-beta.14",
    "@ionic/angular": "4.0.0-beta.0",
    "@ionic/ng-toolkit": "1.0.0",
    "@ionic/schematics-angular": "1.0.0",
    "angularfire2": "^5.0.0-rc.11",
    "cordova-android": "7.1.4",
    "cordova-browser": "^5.0.4",
    "cordova-ios": "^4.5.5",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-file": "^6.0.1",
    "cordova-plugin-file-transfer": "^1.7.1",
    "cordova-plugin-ionic": "^5.2.10",
    "cordova-plugin-ionic-keyboard": "^2.1.3",
    "cordova-plugin-ionic-webview": "^1.2.1",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "core-js": "^2.5.3",
    "dragula": "^3.7.2",
    "firebase": "^5.7.3",
    "hammerjs": "^2.0.8",
    "jquery": "^3.3.1",
    "moment": "^2.22.2",
    "rxjs": "6.2.2",
    "rxjs-compat": "^6.4.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/architect": "^0.7.0-rc.1",
    "@angular-devkit/build-angular": "^0.11.4",
    "@angular-devkit/core": "^0.7.0-rc.1",
    "@angular-devkit/schematics": "^0.7.0-rc.1",
    "@angular/cli": "6.0.8",
    "@angular/compiler": "6.0.9",
    "@angular/compiler-cli": "6.0.9",
    "@angular/language-service": "6.0.9",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~10.5.2",
    "codelyzer": "~4.4.2",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.2",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~2.7.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-keyboard": {},
      "cordova-plugin-ionic": {
        "APP_ID": "873693fa",
        "CHANNEL_NAME": "Master",
        "UPDATE_METHOD": "background",
        "WARN_DEBUG": "true",
        "UPDATE_API": "https://api.ionicjs.com",
        "MAX_STORE": "2",
        "MIN_BACKGROUND_DURATION": "30"
      },
      "cordova-plugin-ionic-webview": {}
    },
    "platforms": [
      "android",
      "ios",
      "browser"
    ]
  }
}

0 个答案:

没有答案