Users losing access to entitlements after switching from active to activeInCurrentEnvironment

  • 13 September 2022
  • 6 replies

Badge +4


Recently I switched my unlock check from look for entitlements in `active`, to looking in `activeInCurrentEnvironment`, in order to prevent people unlocking Pro in TestFlight and carrying it over to production.

This went smoothly for them majority of users, but a couple of users  have reported losing access to their Pro status, despite having active subscriptions/production lifetime purchases. 

I got one user to send through a recording of his error, and the purchase flow went as follows:

  1. Launches app, I call `getCustomerInfo` with a policy of `notStaleCachedOrFetched`, I then pass that to a function call `handlePurchaseInfo`, which determines the user does not have any active entitlements.
  2. They open the Pestle Pro screen, which determines they are ineligible for a trial.
  3. They hit ‘Restore Purchases’, which triggers the RevenueCat restore purchases flow, and I pass the result to the same `handlePurchaseInfo` method from before. In this case, `activeInCurrentEnvironment` is empty, so I throw a `noPurchasesRestored` error, indicating to the user that no purchases were found to restore. 
  4. Then they attempt to subscribe to the plan they know they are on, but get an App Store error, stating “You are currently subscribed to this”, with a renewal date in the future. 
  5. After tapping ‘Ok’ to dismiss the popup, they get a ‘RevenueCat.ErrorCode 2’ error popup, indicating (I believe) a `storeProblemError`.


When I look up their data on RevenueCat, it indicates that they have an active subscription/lifetime in the production environment.

Images of functions:

This is called on attempting to purchase a package from `currentOffering`.

This is restore purchases:


And this is `handlePurchaseInfo`

The affected customers are understanding and would likely be willing to work with me on fixing the issue, but would appreciate some guidance. 

6 replies

Userlevel 3
Badge +5

I think I found the issue! Seems to be this user purchased in box sandbox and live but the entitlement is getting returned with `is_sandbox` flag which is why this is getting filtered out.


Working on a fix!

Badge +4

Any update on this one?

Badge +4

Any updates josh? It’s been over 500 days since I opened this ticket and I would love to close this loophole of sorts.

Userlevel 3
Badge +5

@will Hey, sorry! We have a internal proposal with multiple solutions for this made. We’ll hopefully have an answer for you soon on the approach we are going to take for this!

Badge +4

Hey Josh, any updates here? I’m getting more people finding TestFlight links and buying the Lifetime unlock and I’ve got no real way of preventing their production access right now.

Badge +1

@joshdholtz any update on this? it’s been a long standing issues and affects testing and prod if they cannot be clearly separated.