I'm testing the login/logout system of the RevenueCat SDK on Flutter.
I'm using the Transfer Purchase behavior from https://docs.revenuecat.com/docs/restoring-purchases.
Problem: PurchaserInfo entitlements returns empty after
Purchases.getPurchaserInfo() only returns correct after I refresh the app and call
Steps to reproduce:
1. Enter app, call
Purchases.setup() (without appUserId).
2. Do a subscription purchase
3. Now with the user with subscription, call
Purchases.login(). The user now has a provided app id and has the subscription entitlement.
Purchases.logOut(). Now the user has an anonymous id.
Purchases.getPurchaserInfo() to retrieve the user's entitlements and check if the user has subscription.
Result: the user has no entitlements, even tho the user bought the subscription on that same device.
6. Refresh the app and call
Purchases.setup(). Now when
Purchases.getPurchaserInfo() is called, it returns the subscription bought by the user.
Am I doing something wrong? should I call
Purchases.logOut()? Also, I'm calling setup every time the app opens up, is this correct?
Best answer by ryan
The behavior you’re describing actually sounds like the intended behavior - calling
.logOut() should clear the PurchaserInfo cache and reset the App User ID. At this point the new user should not have access to the subscription.
RevenueCat ties subscription status to an App User ID, not a device, so when the App User ID gets reset it’s not expected for them to have subscription access even if the device does. To regain access, this new App User ID would need to restore purchases.
You should not call Purchases.setup() multiple times - this should only be called once to configure the SDK. Calling this multiple times will configure multiple instances of Purchases, unless you are very careful about managing each instance you may run into trouble where a purchase is made on one instance but you’re checking the subscription status on another instance.
The behavior you’re seeing