android - window.FirebasePlugin.verifyPhoneNumber is not a function 错误

标签 android cordova firebase authentication ionic3

我有一个 ionic 项目(由 Ionic CLI 创建)。我正在尝试将 firebase 的电话身份验证机制集成到登录用户中。根据不同的教程和指南,我知道我必须依赖一些分支,因为官方 firebase 插件尚不支持电话身份验证。

我遇到了—— 1. https://github.com/jestcastro/cordova-plugin-firebase & 2. https://github.com/arnesson/cordova-plugin-firebase

并分别安装它们。

两者结构相似:

window.FirebasePlugin.verifyPhoneNumber(number, timeOutDuration, function(credential) {
    console.log(credential);

    // ask user to input verificationCode:
    var code = inputField.value.toString();

    var verificationId = credential.verificationId;

    var signInCredential = firebase.auth.PhoneAuthProvider.credential(verificationId, code);
    firebase.auth().signInWithCredential(signInCredential);
}, function(error) {
    console.error(error);
});

但是,每当我尝试运行代码(在物理设备或浏览器中)时,它都会给我这个错误 -

ERROR TypeError: window.FirebasePlugin.verifyPhoneNumber is not a function

我试过了-

(<any>window).FirebasePlugin.verifyPhoneNumber(..)

但发现了类似的结果。

Ionic Info 给出了这个:

    @ionic/cli-plugin-proxy : 1.4.11
    @ionic/cli-utils        : 1.12.0
    ionic (Ionic CLI)       : 3.12.0

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.0
    Cordova Platforms  : none
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.0.2
    Node              : v6.11.3
    npm               : 3.10.10
    OS                : Windows 7

Misc:

    backend : pro

package.json

{
  "name": "playground",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "5.0.0",
    "@angular/compiler": "5.0.0",
    "@angular/compiler-cli": "5.0.0",
    "@angular/core": "5.0.0",
    "@angular/forms": "5.0.0",
    "@angular/http": "5.0.0",
    "@angular/platform-browser": "5.0.0",
    "@angular/platform-browser-dynamic": "5.0.0",
    "@ionic-native/camera": "^4.4.0",
    "@ionic-native/core": "4.3.2",
    "@ionic-native/file": "^4.4.0",
    "@ionic-native/file-transfer": "^4.4.0",
    "@ionic-native/splash-screen": "4.3.2",
    "@ionic-native/status-bar": "4.3.2",
    "@ionic/storage": "2.1.3",
    "angularfire2": "^5.0.0-rc.4",
    "cordova-android": "~6.3.0",
    "cordova-plugin-camera": "^3.0.0",
    "cordova-plugin-device": "^1.1.4",
    "cordova-plugin-file": "^5.0.0",
    "cordova-plugin-file-transfer": "^1.7.0",
    "cordova-plugin-firebase": "^0.1.24",
    "cordova-plugin-ionic-webview": "^1.1.16",
    "cordova-plugin-splashscreen": "^4.0.3",
    "cordova-plugin-whitelist": "^1.3.1",
    "firebase": "^4.6.2",
    "ionic-angular": "3.9.2",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "rxjs": "5.5.2",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.18"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.1.0",
    "typescript": "2.4.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "ionic-plugin-keyboard": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-file-transfer": {},
      "cordova-plugin-file": {},
      "cordova-plugin-camera": {},
      "cordova-plugin-firebase": {}
    },
    "platforms": [
      "android"
    ]
  }
}

有没有人遇到过这个问题?你是如何设法解决它的?寻求帮助。

最佳答案

您需要安装cordova-plugin-firebase 使用ionic cordova plugin add https://github.com/jestcastro/cordova-plugin-firebase.git --save.当我们使用 ionic cordova plugin add cordova-plugin-firebase 安装时会发生此错误。

关于android - window.FirebasePlugin.verifyPhoneNumber is not a function 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47511913/

相关文章:

swift 4 : Firebase still creating user even on error?

swift - 如何在标签中从 Firebase 加载数据?

java - 使用匿名内部类 - 添加监听器和传递实例时发生冲突

javascript - document.addEventListener ("touchmove",阻止行为,假); - 阻止我使用溢出 : scroll; - work around?

android - 从手机的内部存储器+外部SD卡存储器中获取所有图像?

javascript - 限制用户在 Android 的输入字段中输入句号

android - 无法运行 PhoneGap 的创建命令

java - 添加邀请、远程配置依赖项时 Firebase 崩溃

android - 基本网络.performRequest : Unexpected response code 301

java - inflater.inflate() 方法调用时出现 InflateException