I'm building a web app that uses Firebase Authentication and I implemented the Google Sign In with the function signInWithPopup. But while on a pc browser the popup is shown correctly, on mobile it immediately closes or doesn't event open and I can't find anywhere on the internet why it happens. The whole project is set up with create-react-app.
signInWithPopup() is for the browser, if you're running Andriod, you need to call signInWithCredential.
signInWithGoogle() {
if (this.platform.is('cordova')) {
return this.gl.login(['email', 'public_profile']).then(res => {
const googleCredential = firebase.auth.GoogleAuthProvider.credential(res.authResponse.accessToken);
return firebase.auth().signInWithCredential(googleCredential);
})
}
else {
return this.afAuth.auth
.signInWithPopup(new firebase.auth.GoogleAuthProvider())
.then(res => console.log(res));
}
}