Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Web Auth Doesn't Work On Mobile Devices?

I was planning to use Firebase's provider authentication for my webapp, but it seems that it doesn't work on mobile devices. the site is live here:

https://cypher.city

Then when you click this button: enter image description here

a popup will appear. And when you click this button: enter image description here

then it should go to a google provider authentication flow.

My code for it looks like this:

var provider = new firebase.auth.GoogleAuthProvider();
  firebase.auth().signInWithRedirect(provider).then((result) => {
    // console.log('@$ signin wiht google worked!' + e +', user is: ' + firebase.auth().currentUser.uid);
    console.log('@$ signin wiht google worked!' + result.user);

  }).catch((e) => {
    console.log('@$ signin wiht google failed!' + e);

    firebase.auth().signInAnonymously().then((user) => {
      console.log('@$ signed in anonymously againQ ' + user.uid);
      // console.log('@$ and firebase knows it: ' + firebase.auth().currentUser.uid);
    }).catch((e) => {
      console.log('@$ signed in anonymously failed ' + e);

    })

  })

The problem is that while this works great on desktop it doesn't work at all on mobile devices. I have tried both "signInWithRedirect" and "signInWithPopup", but when I call these methods on my Huawei Honor phone nothing happens (in any browser).

Am I doing something wrong here or does Firebase web authentication just not work on mobile?

like image 572
Jim Avatar asked Dec 29 '16 16:12

Jim


People also ask

How can I authenticate my mobile number?

In phone authentication, the user has to verify his identity with his phone number. Inside the app user has to enter his phone number after that he will receive a verification code on his mobile number. He has to enter that verification code and verify his identity. So this is how phone authentication works.


2 Answers

This is slightly embarrassing, but it might help someone else. The real issue turned out not to have anything to do with mobile devices, but actually that I was using a custom domain and had forgotten to add it in the auth section on the console. When I tested the production app with chrome dev tools open I could see this error in the console: enter image description here

Adding my custom domain in this section of the firebase console worked: enter image description here

like image 81
Jim Avatar answered Sep 21 '22 15:09

Jim


Some time ago I was trying something similar and for a long time I moved away from this type of login because at the development stage it didn't work for me.

And it was precisely for that reason, because in rea in the development stage I entered my server through an address type 192.157.2.3:3000

try with signInWithPopup and with signInWithRedirect and it didn't work for me

The error is that the request to come from 192.157.2.3:3000 was not supported by firebase, a problem that is simply solved already in production with "firebase deploy".

Here is an example even though Angular is the same

like image 21
Jeff Ruby Avatar answered Sep 22 '22 15:09

Jeff Ruby