❓ RevenueCat Anonymous User Confusion — Purchases Made Without Login
Hi everyone,
I'm currently integrating RevenueCat in a Flutter app and I've run into an issue where a user made a successful purchase anonymously, even though I've explicitly configured the SDK to use Purchases.logIn(userId)
after login.
📦 My Setup
I initialize RevenueCat in main.dart
only after the user has logged in. Here's the relevant initialization code:
🔍 My Questions
-
Can I safely call
Purchases.logOut()
if the user is anonymous? Will it throw or is it a no-op? -
Does
Purchases.logIn(userId)
guarantee that theuserId
will be used for future purchases? Or is there any chance of fallback to an anonymous ID? -
Why is
originalAppUserId
still showing an anonymous ID even after callinglogIn(userId)
?
Shouldn't it update to matchappUserId
after login? -
Does
Purchases.isAnonymous
reliably tell me whether the current user is anonymous?
📎 Notes
-
The
userId
is definitely non-null and only passed after the user has logged in. -
I’m using a guest user pattern — the SDK is initially configured in
main.dart
without a user ID to allow the guest to browse offerings and see subscription info. -
At the time of purchase, I log in the user and call
initRevenueCat()
with their customuserId
. -
Despite calling
logIn(userId)
andrestorePurchases()
, one of the users was still tracked under an anonymousappUserId
, and their purchase wasn’t linked to their logged-in account.
Today i lose a subscription and a in-app purchase because i have to refund ,