Search code examples
angularfirebasefirebase-authenticationcapacitor

Angular capacitor app crashes on firebase login due to redirect


Im using Angular2 and Capacitor for a project testing out capacitor. I use Firebase for login and every time I try login it crashes the capacitor project on android.
It seems that the crash happens around the redirect/popup. I firstly tried the signInwithPopup(). I found out that this was not supported within mobile environments so I moved to the signInWithRedirect

let provider = new firebase.auth.GoogleAuthProvider();
provider.addScope('profile');
provider.addScope('email');
firebase.auth().signInWithRedirect(provider);
firebase.auth().getRedirectResult().then(function (result) {
   console.log('result', result);
});

This also crashes as it returns {user: null} but it works on browser and on browser both methods work.
Another method Ive seen from the ionic forums is that the getRedirectResult should be moved to the ngOnInit so that when the redirect returns to the page you listen for the redirect straight away but this also doesnt work. Has anyone impemented this in Capacitor using Angular2 project?
Any help or ideas would be appreciated


Solution

  • I was a bug in that version, it’s fixed in latest beta (17)