bug: authStateChange never fires.
See original GitHub issuePlugin(s): “@capacitor-firebase/authentication”: “^0.5.0”
Platform(s): Android
Current behavior:
When using const result = await FirebaseAuthentication.signInWithGoogle()
for example, the login is successful and result.user
is returned. However, authStateChange
is never fired. Note that this works in web, but NOT on Android.
Expected behavior:
authStateChange
needs to be fired on any change in auth state, e.g. re-opening app or signing out.
Steps to reproduce:
Related code:
// capacitor.config.json
"plugins": {
"FirebaseAuthentication": {
"skipNativeAuth": false,
"providers": ["twitter.com", "google.com", "facebook.com"]
},
}
// main.ts
import { FirebaseAuthentication } from "@capacitor-firebase/authentication";
FirebaseAuthentication.removeAllListeners().then(() => {
FirebaseAuthentication.addListener("authStateChange", (result) => {
if (result.user) {
// this never fires
} else {
// this never fires
}
});
});
// Login.vue
const signInWithGoogle = async () => {
try {
const result: SignInResult = await FirebaseAuthentication.signInWithGoogle();
if (result.user) {
return result.user;
}
} catch (err) {
console.log(err);
}
};
Other information: Some potentially relevant logs from Android Studio:
V/Capacitor/FirebaseAuthenticationPlugin: Notifying listeners for event authStateChange D/Capacitor/FirebaseAuthenticationPlugin: No listeners found for event authStateChange V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 81763094, pluginId: FirebaseAuthentication, methodName: addListener V/Capacitor: callback: 81763094, pluginId: FirebaseAuthentication, methodName: addListener, methodData: {“eventName”:“authStateChange”}
Also, it looks like there’s a similar issue that was closed but with no real solution, https://github.com/capawesome-team/capacitor-firebase/issues/56
Capacitor doctor:
Latest Dependencies:
@capacitor/cli: 3.6.0
@capacitor/core: 3.6.0
@capacitor/android: 3.6.0
@capacitor/ios: 3.6.0
Installed Dependencies:
@capacitor/cli: 3.4.3
@capacitor/core: 3.4.3
@capacitor/android: 3.4.3
@capacitor/ios: 3.4.3
Issue Analytics
- State:
- Created a year ago
- Comments:41 (16 by maintainers)
I will look at it again and possibly consult with the Capacitor team to see what solution they recommend.
@Guiditox Thank you for testing!