Question

Android checking subscription status always returns true, even when cancelled

  • 20 May 2023
  • 1 reply
  • 13 views

Badge

Im testing in play store test mode and i activate the subscription which works fine, but when i cancel the test subscription the entitlement for the user is always returning true. On revenue cat dashboard the subscription is cancelled, so i assume this is a caching thing? If so can someone explain more deeper why it doesn’t shoot a network request to grab the updated sub value?

thanks

 

override suspend fun isSubscribed(): Flow<Boolean> = callbackFlow {    Purchases.sharedInstance.getCustomerInfo(        callback = object : ReceiveCustomerInfoCallback {            override fun onError(error: PurchasesError) {                Log.e(TAG, "onError: ${error.message}")            }            override fun onReceived(customerInfo: CustomerInfo) {                Log.d(TAG, "onReceived: ${customerInfo.entitlements["Premium"]?.isActive}")                trySend((customerInfo.entitlements["Premium"]?.isActive == true))            }        }    )    awaitClose()}

1 reply

Userlevel 3
Badge +6

Hey @tapmaxalf ,

 

This does seem to be relating to how customer info is being cached, we have a useful document explaining in more detail the caching process which can be found here: https://www.revenuecat.com/docs/caching#customerinfo

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. The cache will also be updated in the background when the app restarts even if the cache is not older than 5 minutes, as well as on the app foreground after 5 minutes has passed. These background updates can be listened to with the CustomerInfo listener. See here for information on the CustomerInfo's fetchPolicy.

The latest CustomerInfo is automatically fetched and cached when the Purchases SDK is configured and throughout the lifecycle of your app, so in most cases the getCustomerInfo() method will return synchronously. It is safe to call getCustomerInfo()  as often as needed and is a good idea to call it any time a user accesses premium content.

 

I hope that helps! 

Reply