Question

iOS customerInfo details

  • 30 November 2022
  • 2 replies
  • 191 views

Badge +2

Hi.

I’m using iOS SDK.

  1. How often does CustomerInfo update from network (vs cache)?
  2. Can I influence the update frequency?
  3. Can I force a network update?

Many thanks,


2 replies

Userlevel 4
Badge +6

Hey There! 

 

Hopefully this helps answer some of your questions: 

  • How often does CustomerInfo update from network (vs cache)?
    • CustomerInfo updates are not pushed to your app from the RevenueCat backend, updates can only happen from an outbound network request to RevenueCat.
    • Whenever CustomerInfo is called, it will be up to date with the latest object. If a purchase is made, CustomerInfo will be updated, and cache will be ignored.
    • The cache is updated every 5 minutes automatically.
  • Can I influence the update frequency?
    • You can respond to any changes in CustomerInfo by conforming to an optional delegate method, purchases:receivedUpdated:. This will fire whenever we receive a change in CustomerInfo on the current device and you should expect it to be called at launch and throughout the life of the app.
    • The SDK caches the user's subscription information to reduce your app's reliance on the network. Users who unlock entitlements will be able to access them even without an internet connection. The SDK will update the cache if it's older than 5 minutes, but only if you call getCustomerInfo(), make a purchase, or restore purchases, so it's a good idea to call getCustomerInfo() any time a user accesses premium content(this will help ensure that it is up-to date frequently).
  • Can I force a network update?
    • The CustomerInfo object is updated whenever a purchase or restore occurs and periodically throughout the lifecycle of your app. The latest information can always be retrieved by calling getCustomerInfo(): This can be 

      called frequently throughout your app. Since the SDK updates and caches the latest CustomerInfo when the app becomes active, the completion block won't need to make a network request in most cases.

Badge +1

Hi -- I have a case where I would like to be able to clear this cache behind the scenes.  I have a Web-based checkout that uses Stripe’s integration with RevenueCat, and if a call to `Purchases.customerInfo` has happened to have occurred less than 5 minutes prior to that checkout (which is pretty likely, given the fact that they have probably been using the app shortly before deciding to make the purchase), then the purchased features will not be available until that cache is cleared.

 

I’d love to provide a button in the app that my ‘Purchase Complete’ screen could drive the user to, which would clear the customerInfo cache, and give them immediate access to the feature, rather than asking them to kill and re-open the app.  Based on the answer above, I don’t _think_ that is currently possible, but would love to learn otherwise!

Reply