Environment
Describe the bug
When I open the app and login with Facebook, it works fine. But if I logout and try to re-login (without closing the app), it doesn't work. It seems the method firebase.login() never resolves. I don't get any error messages. I only get it to work again if I close and re-open the app.
To Reproduce
1) Login with firebase.login:
firebase.login({
type: firebase.LoginType.FACEBOOK,
facebookOptions: { scope: ['public_profile', 'email'] }
}).then(user => {
})
.catch(error => {
})
2) Logout via firebase.logout()
3) Try to login again like in step (1), without closing the app
Additional context
Digging into the firebase.android.js file, I see that when I login for the first time, the method logInWithReadPermissions is called and after some time the callback onSuccess is also called, indicating successful login, as expected. But when I logout and click in login again, it seems that logInWithReadPermissions is called, but I never get a callback.
I have the exact same issue :( Waiting for the reply from Eddy.
I've managed to fix the issue, but I'm not sure it's the best solution. I'm gonna leave it here for your consideration, @EddyVerbruggen .
On the firebase.android.js, I removed the following bit of code from the firebase_common_1.firebase.init function to the firebase_common_1.firebase.login, right at the beginning:
if (typeof (com.facebook.FacebookSdk) !== "undefined") {
com.facebook.FacebookSdk.sdkInitialize(com.tns.NativeScriptApplication.getInstance());
fbCallbackManager = com.facebook.CallbackManager.Factory.create();
var callback_1 = function (eventData) {
if (eventData.requestCode !== GOOGLE_SIGNIN_INTENT_ID) {
appModule.android.off(appModule.AndroidApplication.activityResultEvent, callback_1);
fbCallbackManager.onActivityResult(eventData.requestCode, eventData.resultCode, eventData.intent);
}
};
appModule.android.on(appModule.AndroidApplication.activityResultEvent, callback_1);
}
I get the same issues as well, firebase.login() never resolves if we relog on logged out account (only happen on facebook, google seems work just fine), BUT in my condition, it only happen if I relog with different account.
how to reproduce the error:
Sometimes it goes to this error:
Error while trying to login with Fb User logged in as different Facebook user.
I've tried @hcgustavo fix, it goes error directly..
@hcgustavo Thanks for the details (and others as well, for chiming in). I must admit that code looks a bit suspicious. I'll take a look!
Thanks @EddyVerbruggen !
Thanks @EddyVerbruggen