this.firebaseAuthentication.verifyPhoneNumber(...).then is not a function in ionic 4

I am trying to add firebase phone authentication to my app and I used this tutorial to help me https://www.youtube.com/watch?v=R906OGFurJg. I am getting an ERROR TypeError: this.firebaseAuthentication.verifyPhoneNumber(...).then is not a function in my console for the line inside the function. This function sends the number and in return we get the code verification message

app.module.ts

import { AngularFireModule } from '@angular/fire';
import { environment } from '../environments/environment';
import { FirebaseAuthentication } from '@ionic-native/firebase-authentication/ngx';
@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  // tslint:disable-next-line: max-line-length
  imports: [AngularFireModule.initializeApp(environment.firebase, 'test'),
],
  providers: [
    
    FirebaseAuthentication,
    { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

.ts file

import { FirebaseAuthentication } from '@ionic-native/firebase-authentication/ngx';

export class Page two {

verificationID: string = "";
numpad: any;
selectedCode: any;

constructor(public firebaseAuthentication: FirebaseAuthentication) {}

btnClicked(){

  const tell = this.selectedCode + this.numpad;

  this.firebaseAuthentication.verifyPhoneNumber(tell, 30000).then((verificationID) => {

    console.log(verificationID);

    this.verificationID = verificationID;

  }).catch((error) => {

  

  });

    this.startTimer(1);

}

package.json likely relevant.

Package.json

{
  "name": "app",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://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": "~8.1.2",
    "@angular/compiler": "~8.1.2",
    "@angular/core": "~8.1.2",
    "@angular/fire": "^5.3.0",
    "@angular/forms": "~8.1.2",
    "@angular/platform-browser": "~8.1.2",
    "@angular/platform-browser-dynamic": "~8.1.2",
    "@angular/router": "~8.1.2",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/firebase-authentication": "^5.19.1",
    "@ionic-native/image-picker": "^5.16.0",
    "@ionic-native/image-resizer": "^5.15.0",
    "@ionic-native/splash-screen": "^5.0.0",
    "@ionic-native/status-bar": "^5.0.0",
    "@ionic/angular": "^4.7.1",
    "@mobiscroll/angular-lite": "^4.8.1",
    "@types/crypto-js": "^3.1.43",
    "cordova-android": "^8.1.0",
    "cordova-plugin-firebase": "git+https://github.com/jestcastro/cordova-plugin-firebase.git",
    "cordova-plugin-firebase-authentication": "^3.0.2",
    "cordova-plugin-telerik-imagepicker": "^2.3.3",
    "cordova-support-android-plugin": "^1.0.1",
    "cordova-support-google-services": "^1.3.2",
    "core-js": "^2.5.0",
    "crypto-js": "^3.1.9-1",
    "firebase": "^7.6.2",
    "flag-icon-css": "^3.4.5",
    "intl": "^1.2.5",
    "ionic-angular": "3.9.9",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionic-select-searchable": "^2.10.0",
    "ionic-selectable": "^4.5.0",
    "ngx-flag-picker": "^8.0.0",
    "rxjs": "^6.5.4",
    "rxjs-compat": "^6.5.3",
    "sha1": "^1.1.1",
    "tslib": "^1.9.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/architect": "~0.801.2",
    "@angular-devkit/build-angular": "^0.803.23",
    "@angular-devkit/core": "~8.1.2",
    "@angular-devkit/schematics": "~8.1.2",
    "@angular/cli": "~8.1.2",
    "@angular/compiler": "~8.1.2",
    "@angular/compiler-cli": "~8.1.2",
    "@angular/language-service": "~8.1.2",
    "@ionic/angular-toolkit": "~2.0.0",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "^5.0.0",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-ionic-webview": "^4.1.3",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.4.3"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-telerik-imagepicker": {},
      "cordova-plugin-firebase-authentication": {},
      "cordova-plugin-firebase": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-plugin-ionic-keyboard": {}
    },
    "platforms": [
      "android"
    ]
  },
  "config": {
    "ionic_copy": "./config/copy.config.js"
  }
}

In that case, see if the problem persists when you are running on a device, and not just in an ordinary browser.

  1. You need to upgrade your cordova to 9.0.0
  2. Install again step by step from here https://ionicframework.com/docs/native/firebase-authentication
  3. Go to firebase console => https://console.firebase.google.com/
  4. Authentication => Tab Sign-In method
  5. Set Active Phone Status
  6. Maybe u need to set optional phone number for debug, no SHA required.
1 Like