question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SMS Number verification using AngularFire2 instance.

See original GitHub issue

Hey there,

I plan on using AngularFire2 and not reference firebase (the library) directly.

While trying to get Phone number authentication I was unable to do so.

While using the reCapcha verifier you have to use the following.

window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('sign-in-button', {
  'size': 'invisible',
  'callback': function(response) {
    // reCAPTCHA solved, allow signInWithPhoneNumber.
    onSignInSubmit();
  }
});

note here that we have the use new firebase.auth.

Is there an AngularFire2 way of doing the same?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Jul 18, 2018

For anyone trying this with Ionic or Cordova please consider, https://stackoverflow.com/questions/44081040/ionic2-authentication-firebase

1reaction
midhunadarvincommented, Mar 21, 2018

@prantikv For anyone else stuck with phone authentication. You have to write it like this inside of your component.

Add this element to your component template .

<div id="recaptcha-container"></div>

Inside your component class

import * as firebase from 'firebase/app';
...
ngAfterViewInit() {
    //Called after ngAfterContentInit when the component's view has been initialized. Applies to components only.
    //Add 'implements AfterViewInit' to the class.
    this.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container');
  }

and finally the login method. Here appVerifier argument passed should be the recaptchaVerifier.

// Phone Login
  phoneLogin(phoneNumber: any, appVerifier: any) {
    this.AngularFireAuth.auth.signInWithPhoneNumber(phoneNumber, appVerifier)
      .then((confirmationResult) => {
        // SMS sent. Prompt user to type the code from the message, then sign the
        // user in with confirmationResult.confirm(code).
        console.log(confirmationResult);
      }).catch((error) => {
        // Error; SMS not sent
        // ...
      });
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

AngularFire2 Authentication - KhoPhi's Blog
Firebase 3 is the cool kid. How do you Auth using Angular2 with Firebase? See in this AngularFire2 Authentication tutorial.
Read more >
Firebase Authentication in Angular 11 with AngularFire2
This guide help you understand the Firebase Authentication in Angular application using the AngularFire2 package.
Read more >
Login with Phone number in an Angular App using Firebase ...
In this video, we'll implement Phone Sign-In in our Angular App.This video is a preview of a paid Udemy Course titled Angular Authentication...
Read more >
Basic Firebase CRUD Operations in Angular With AngularFire2
In this quick post you'll see how to perform basic CRUD operations on a Firebase database instance in your Angular 2+ apps.
Read more >
Using angularfire2 build Angular and Firebase Application ...
This library will fascinating us to develop an Angular application in just no time. So in this tutorial I am going to show...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found