Dear RevenueCat Support,
I am currently developing a React Native application that uses the react-native-purchases
library for handling in-app purchases. I have encountered an issue where the session related to the purchases remains active even after a user logs out.
I am using Firebase to authenticate, and the SDK is not generating anonymous ID like (RC: …). But the same ID stored in (originalAppUserId: '8NG2...') which is the same as the firebase User, is forever stored in the cache unless the app is deleted and redownloaded. I am wondering what the best practice is that is not .logOut, due to creating anonymous ID. I am aware of restorePurchases but I am gearing away from a button to pass the conditional renders.
Also, is it appropriate to leave the .logIn in the authStateChange function for logging in with saved authentication data or to use the login just during the initial login part of the code.
Thanks for your guys help. I hope to hear back soon!
APP.js
function onAuthStateChanged(user) {
setUser(user);
purchasesInit()
if (initializing) setInitializing(false);
}
const purchasesInit = async () => {
if (user && user.uid) {
const { customerInfo, created } = await Purchases.logIn(user.uid);
console.log("TESTING")
}
};
---------------------------------------------------------------
Logout.js
const handleLogout = () => {
auth()
.signOut()
.then(() => {
console.log("User signed out!");
if (userData?.email === null || userData?.email === "") {
const uidToSave = userData?.uid;
saveUID(uidToSave);
} else {
clearData();
}
})
.catch((error) => {
console.error("Sign out error:", error);
});
};