-
Notifications
You must be signed in to change notification settings - Fork 2.3k
-
I would like to ask for advise on what is the most reliable way to switch from the firebase/auth to @react-native-firebase/auth without user losing the session between the app upgrades.
Currently I am using AsyncStorage as a persistor layer in the following way:
import AsyncStorage from "@react-native-async-storage/async-storage";
import { initializeAuth, getReactNativePersistence } from "firebase/auth";
...
export const auth = initializeAuth(app, {
persistence: getReactNativePersistence(AsyncStorage),
});
After moving to native SDK I have now:
import AsyncStorage from "@react-native-async-storage/async-storage";
import { getAuth } from "@react-native-firebase/auth";
import { setReactNativeAsyncStorage } from "@react-native-firebase/app";
...
setReactNativeAsyncStorage(AsyncStorage);
...
export const auth = getAuth(app);
When tried the upgrade the session persistence seemed to work, as the user didn't get logged out but I experienced some odd behaviour as well:
- I experienced that in some cases between the upgrades the session persisted but it was a different user (?). I use several test users, I have regular login as well as Apple/Google auth. As if the tokens have been stored independently and one SDK read it from different place than the other
- occasionally the Firestore queries were failing (can't say 100% why but could be the permission-denied error). Btw I have migrated also the
firestorerelated module (firebase/firestoreto@react-native-firebase/firestore) - the offline behaviour that I expected to be switched on by default in native SDK doesn't seem to work (maybe a separate issue here)
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment