Tahniat Ashraf
Tahniat Ashraf

Reputation: 1050

window.FirebasePlugin.verifyPhoneNumber is not a function error

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.

I came across - 1. https://github.com/jestcastro/cordova-plugin-firebase & 2. https://github.com/arnesson/cordova-plugin-firebase

and installed them separately.

Both of them have similar structure :

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

I have tried -

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

but found similar result.

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.

Upvotes: 1

Views: 2395

Answers (2)

Musab
Musab

Reputation: 1127

This worked for me

  1. cordova plugin remove cordova-plugin-firebase
  2. cordova plugin add https://github.com/jestcastro/cordova-plugin-firebase.git

Upvotes: 1

Samaludheen
Samaludheen

Reputation: 176

You need to install cordova-plugin-firebase using ionic cordova plugin add https://github.com/jestcastro/cordova-plugin-firebase.git --save.when we install using ionic cordova plugin add cordova-plugin-firebase this error occures.

Upvotes: 1

Related Questions