firebasefirebase-authenticationrecaptcha

Firebase Phone Auth - RecaptchaVerifier Type Error


I am trying to implement Firebase Phone Number Authentication as described Here

However when I try try and create the RecaptchaVerifier object as per the docs:

window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container');

I get the following error:

Uncaught TypeError: Cannot read property 'bind' of undefined at new FirebaseAppImpl.(anonymous function)

which seems to be from this line of code in the Firebase SDK:

 var serviceFxn = this._getService.bind(this, name);

Has anyone successfully implemented this?


Solution

  • I was wrongly trying to create the RecaptchaVerifier on the already initialised FirebaseApp rather than the actual module. This code is actually working fine:

    window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container');