Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Migrate Auth from JS SDK to native SDK #8523

Unanswered
gpawlik asked this question in Q&A
Discussion options

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 firestore related module (firebase/firestore to @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)
You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /