I'm facing a challenge with managing trial offers for anonymous users on new devices
The Problem
RevenueCat’s checkTrialOrIntroductoryEligibility is iOS-only, so I’ve built a workaround using allPurchasedProductIdentifiers to determine trial eligibility. It works like this:
const customerInfo = (await Purchases.getCustomerInfo()).customerInfo;
const numPurchases = customerInfo.allPurchasedProductIdentifiers.length;
if (numPurchases > 0) {
setShowTrialOffer(false);
}
This works as long as the user stays on the same device because RevenueCat caches the Anonymous ID. However, if the user:
- Starts a free trial
- Cancels the trial before it ends
- Deletes and reinstalls the app (or switches devices)
RevenueCat creates a new Anonymous ID when the user reopens the app. As a result, allPurchasedProductIdentifiers will be empty. This allows the user to start another free trial, repeating the process indefinitely.
Potential Solution: syncPurchases
Calling restorePurchases could prevent this, but it may trigger OS-level sign-in prompts, so RevenueCat recommends syncPurchases instead. However, the documentation is unclear:
- General Docs:
"
syncPurchasesallows you to programmatically trigger a restore. This method, likerestorePurchases, reactivates any content previously purchased from the same store account." - SDK Docs:
"
syncPurchasessends all purchases to the RevenueCat backend. Call this when using your own subscription implementation anytime a sync is needed, like after a successful purchase."
These descriptions seem contradictory:
- Does
syncPurchasespull past purchases from the app stores? - Or does it just sync purchases from my app to RevenueCat?
Key Questions
If syncPurchases does pull past purchases from the app stores, what happens in this scenario?
- A user starts a trial (RevenueCat creates
AnonymousAppUserID#1) - The user deletes and reinstalls the app (RevenueCat creates
AnonymousAppUserID#2) - The user opens the app, and I call
syncPurchases.
After calling syncPurchases:
- Will
CustomerInfo.originalAppUserIdreturnAnonymousAppUserID#1? - Will
CustomerInfo.allPurchasedProductIdentifiersinclude the original trial? - Will future webhooks for the user have
AnonymousAppUserID#1in theoriginal_app_user_idfield?
Any clarity would be greatly appreciated!
Chris
