Skip to main content
Solved

PurchaserInfo.requestDate is always stale when I grant a user with lifetime access

  • 26 October 2021
  • 1 reply
  • 117 views

Forum|alt.badge.img+2

When the phone is offline I am relying on these 2 parameters to make sure the user has access to the premium entitlement:

  • purchaserInfo.entitlements[premiumEntitlementID].isActive == true
  • purchaserInfo.requestDate is not older than 24h

If the premium entitlement is active but the purchaserInfo.requestDate is older than 24h, I block the access to the premium features and kindly request the user to connect to the internet to keep enjoying those features.

Now for some reason I have noticed that if I grant a user with lifetime access, it seems like purchaserInfo.requestDate gets roughly stuck to the same date/time as when I granted lifetime access. The user can thus not use the premium features after 24h even if the phone has an active internet connection. This obviously defeats the purpose of granting lifetime access.

To give more details I call Purchases.shared.purchaserInfo() whenever the app becomes active and also as the app is active, whenever the internet connection becomes active. I save the purchaserInfo returned by its block in a class variable for later use: like just before the user tries to access a premium feature.

As a workaround to this issue I call:

if purchaserInfo.entitlements[premiumEntitlementID].productIdentifier == "rc_promo_premium_lifetime" {

   // Special case even though purchaserInfo.requestDate is long stale, the user can still access premium features while in offline or online mode for that matter. 
   return true
}

 

Am I missing something? Or is it the intended behaviour that purchaserInfo.requestDate is always stale when lifetime access was granted?

Best answer by jazmine

Hey @Josselin , 

The SDK will update the cache if it's older than 5 minutes when online, but only if you call getPurchaserInfo(), make a purchase, or restore purchases, so it's a good idea to call getPurchaserInfo() any time a user accesses premium content. 

 

When offline the  getPurchaserInfo()will return whatever is in the cache. Additionally when you call getPurchaerInfo() and the device is offline we will return whatever we have cached. 

View original
Did this post help you find an answer to your question?

1 reply

jazmine
Forum|alt.badge.img+7
  • Dedicated Contributor
  • 122 replies
  • Answer
  • November 5, 2021

Hey @Josselin , 

The SDK will update the cache if it's older than 5 minutes when online, but only if you call getPurchaserInfo(), make a purchase, or restore purchases, so it's a good idea to call getPurchaserInfo() any time a user accesses premium content. 

 

When offline the  getPurchaserInfo()will return whatever is in the cache. Additionally when you call getPurchaerInfo() and the device is offline we will return whatever we have cached. 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings