Hi,
We have an example app with some more context on how to implement this: https://github.com/RevenueCat/react-native-purchases/blob/e0128b4254d5c5f7e399b8c85fad1495a3ea08db/examples/MagicWeather/src/screens/UserScreen/index.js#L35
I’d suggest taking a look at that and seeing if it matches your implementation.
The only thing I can think of now is to have a 5 minute setTimeout() in my app but that seems far from ideal.. :/
Yeah, don’t do that
Thanks.
I’m working with React Native Android and trying something like this now based on the example you linked to:
const getRevCatUserDetails = async () => {
const customerInfo = await Purchases.getCustomerInfo();
modifyPaidStatus(customerInfo.activeSubscriptions.length > 0);
};
useEffect(() => {
getRevCatUserDetails();
}, >]);
useEffect(() => {
Purchases.addCustomerInfoUpdateListener(getRevCatUserDetails);
return () => {
Purchases.removeCustomerInfoUpdateListener(getRevCatUserDetails);
};
});
Now, if I activate the subscription, see it’s active, then wait 5 minutes or more and click on some button to trigger the check like this:
const handleOnClickItem = async (item: Item) => {
await getRevCatUserDetails();
await getRevCatUserDetails(); //twice on purpose to check if status is really no active
//do stuff with item and trigger other functionality in the code, async
}
The subscription still active, and only resets later..
I’m not sure I understand why even after calling the method twice in a row, awaiting it regardless of listeners it should update the status, but the status does not change..
I must add that right after the handleOnClickItem() function ends execution, the status DOES update. So I think it’s a delay of some sort from the servers..? Dunno, this behavior seems strange.
Adding that even if I try something like this:
await Purchases.getCustomerInfo();
await Purchases.syncPurchases();
Purchases.getCustomerInfo().then((info) => {
modifyPaidStatus(info.activeSubscriptions.length > 0);
});
it still doesn’t update correctly...
Hi,
In this case what is most likely happening is that our backend is not refreshing the receipt within 5 minutes. But the receipt can be updated more quickly if you setup platform server notifications