Question

Users losing access to entitlements after switching from active to activeInCurrentEnvironment

  • 13 September 2022
  • 1 reply
  • 24 views

Badge +2

Hey,

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. 


1 reply

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!

Reply