Solved

How can i Reset the react-native-purchases cache without .logOut?

  • 6 January 2024
  • 2 replies
  • 98 views

Badge +3

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);
});
};


  

icon

Best answer by resellology 6 January 2024, 22:43

View original

2 replies

Badge +3

A good example of my issue is when I log into a subscribed account, then I log out. I log into a new account that has no subscription on it. It bypasses the whole paywall and allows the unpaid in the app. I log the const customerInfo = await Purchases.getCustomerInfo(); to console and app_id is the same as the user that has already purchased. 

Badge +3

Fixed 👍

 

Reply