Skip to main content

Hello,

I’m using the latest Revenue Cat SDK (8.4.0) and i’m trying to do the following use case in Sandbox :

  • Subscribe to a monthly subscription
  • Immediately refund it from Revenue Cat dashboard
  • Open the app and see that the premium content is no longer available for the user

I’m calling

Purchases.sharedInstance.getCustomerInfoWith(fetchPolicy = CacheFetchPolicy.NOT_STALE_CACHED_OR_CURRENT) { customerInfo ->
checkStatus(customerInfo)
}

And always get this Logs :

 

Retrieving customer info with policy: NOT_STALE_CACHED_OR_CURRENT
ℹ️ Checking if cache is stale AppInBackground true
ℹ️ Vending CustomerInfo from cache.

 

Something weird here, is that AppInBackground is always returning TRUE.This means that the cache will not be stale before the 25 hours delay and never within the 5 minutes delays for foreground application. Then the cache is never updated

I’m initializing my Purchases only once in the onCreate of my Application class

if (BuildConfig.DEBUG) {    Purchases.logLevel = LogLevel.VERBOSE}Purchases.configure(PurchasesConfiguration    .Builder(this, "API_KEY")    .build())

I’ve put breakpoints in the 

PurchasesOrchestrator : 
onAppBackgrounded and onAppForegrounded

Where the appInBackground is updated, but these methods are never called

I’ve found out that the same questions was asked here : 

 But there is no solution provided

 

Thank you for your help :)

Hello, nobody has this encoutered this issue ?


Hi @Mathieu-D,

Thank you for reporting this. I’m going to bring this up with our mobile engineers and let you know what they say.


Hi @Mathieu-D 

I’ve tried reproducing it and I can’t. I’ve put breakpoints in onAppForegrounded, and it gets called, so I am unsure what’s going on.

Two things that might be helpful to check out:
1. Can you share the output of `./gradlew dependencies`. I would like to see what version of the `androidx.lifecycle` library is getting pulled.
2. Does this happen with code shrinking disabled by setting `minifyEnabled` to false as well?  https://developer.android.com/build/shrink-code#enable I wonder if something is breaking Lifecycle
3. Can you share more complete logs?

Thank you


Hello !

Of course, you’ll find the output of gradlew dependencies attached

I’m testing it on debug mode so shrinking/minify is not enabled

I’m attaching too the firsts logs of Revenue cat SDK when I start my app

 

 

About lifecycle versions i have in my libs.version

lifecycle-process = { group = "androidx.lifecycle", name = "lifecycle-process", version = "2.7.0" }
lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version = "2.7.0" }
lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version = "2.8.2" }
lifecycle-livedata-ktx = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version = "2.7.0" }
lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version = "2.7.0" }

EDIT : I’ve tried to update to the latest lifecycle version 2.8.4 and it’s the same.

Thanks


Thank you for sharing that @Mathieu-D 

I have tested with 2.8.2, which is the version your Gradle is picking and it also works for me.

Some ideas here:
1. Can you share your merged AndroidManifest.xml (removing anything compromising of course). I would like to see if there are anything related to androidx.startup in there
2. How are you using Lifecycle yourself? I wonder if there’s any interference there, although it shouldn’t.
3. Do you use any other library like workmanager that could maybe be causing issues?
4. Can you set a breakpoint in the init of ProcessLifecycleOwner and confirm if it gets called?
 


Thank you


Hello @Cesar,

I’ve check in my Manifest and yes indeed i was using WorkManager and custom WorkManager initalization. So i’ve added this in my Manifest :

 <!-- If you want to disable android.startup completely. -->
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
tools:node="remove">
</provider>

After removing it, the callback methods for back/foreground was being trigger on RevenueCat SDK 🙌

But I needed this lines in the Manifest to make my WorkManager … work :D

Found out in the Google documentation that i only need to add

 <provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">
<!-- If you are using androidx.startup to initialize other components -->
<meta-data
android:name="androidx.work.WorkManagerInitializer"
android:value="androidx.startup"
tools:node="remove" />
</provider>

 With this change both is OK : WorkManager and RevenueCat lifecycle events 👌

It could be something to add in your SDK documentation for Android, if someone experiment the same issue ? ^^

Thank you for your help 


Thank you so much for reporting back that you managed to fix it. I have taken the opportunity to add a little warning banner to our public docs hoping that it will prevent this from happening to someone else.