I'm trying to send an email verification to the user when they sign up. The user gets added to firebase but the email is not sent. I logged the error to the console and it says
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);
}
}
}