I have encountered an issue while attempting to send an email verification to users upon signing up. Even though the user is successfully added to Firebase, the email verification is not being sent out. Upon checking the console for errors, I found the following message:
Cannot read property 'sendEmailVerification' of undefined
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { User } from "../../models/user";
import { AngularFireAuth } from "angularfire2/auth";
import * as firebase from 'firebase';
@IonicPage()
@Component({
selector: 'page-register',
templateUrl: 'register.html',
})
export class RegisterPage {
user = {} as User
constructor(private afAuth: AngularFireAuth,
public navCtrl: NavController, public navParams: NavParams) {
}
async register(user: User) {
try {
const result = await this.afAuth.auth.createUserWithEmailAndPassword(user.email, user.password)
.then(res => {
var auth = firebase.auth();
this.auth.sendEmailVerification(user.email)
this.navCtrl.setRoot('LoginPage');
}
}
catch (e) {
console.log(e);
}
}
}