verifyPhoneNumber不是函数错误

verifyPhoneNumber不是函数错误

本文介绍了window.FirebasePlugin.verifyPhoneNumber不是函数错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a ionic project (created by Ionic CLI). I am trying to integrate firebase's phone authentication mechanism to login user. As per different tutorials and guidelines, I knew I had to rely upon some forks as the official firebase plugin doesn't have phone authentication support yet.

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

I came across -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);
});

但是,每当我尝试在物理设备或浏览器上运行代码时,都会出现此错误-

But, whenever I try to run the code (on physical device, or in browser), it gives me this error -

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

我已经尝试过-

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

但发现了相似的结果.

Ionic Info提供了此信息:

Ionic Info gives this :

    @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"
    ]
  }
}

还有其他人遇到过这个问题吗?您如何解决呢?寻求帮助.

Has anyone else faced this issue? How have you managed to solve it? Seeking help.

推荐答案

这对我有用

  1. cordova插件删除cordova-plugin-firebase
  2. cordova插件添加 https://github.com/jestcastro/cordova-plugin- firebase.git

这篇关于window.FirebasePlugin.verifyPhoneNumber不是函数错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 08:27