I'm experiencing unexpected behavior when using a custom App User ID with react-native-purchases
.
At app start, I call Purchases.configure
exactly once (on every login) and immediately provide the Cognito sub
as appUserID
:
const cognitoSub = await Storage.getUser(); Purchases.configure({ apiKey: ..., appUserID: cognitoSub, });
However, when calling await Purchases.logIn(cognitoSub)
shortly after, the customerInfo.originalAppUserId
still returns an anonymous ID ($RCAnonymousID...
).
Even when purchases are restored, the originalAppUserId
is still the anonymous ID, not the custom one passed to configure()
. This leads to purchases being restorable across multiple user accounts on the same device, which should not be possible.
What’s strange is that in TestFlight restoring purchases with a different account on the same device failed, as intended.
But in production, any user on the same device can restore the purchase, even with a different Cognito ID.
I’m using the latest libraries:
"react-native-purchases": "^8.9.2", "react-native-purchases-ui": "^8.9.2"
Am I missing something? I read in the docs that .configure()
must be called only once and after the custom App User ID is available — which I’m doing. Still, an anonymous ID is being generated. I have experienced this only on iOS so far.
Any help is appreciated!
Edit:
I’ve checked the docs again and found the Restore Behavior. I have changed my Project Settings to Keep with original user id. I will check if that fixes the issue!
https://www.revenuecat.com/docs/projects/restore-behavior