Skip to main content

Hi, I’m using the latest version of RevenueCat SDK on Android 5.7.1. I’ve noticed in debug logs that `AppInBackground` is always `true` even through the app is at foreground.

This has caused some issues, such as cache not being updated in time. IIUC if app is in background, the SDK only updates cache once a day instead of the default 5 mins. Also, I realise that offerings are not being cached at app launch. When I start the activity with paywall, there’s always a noticeably delay of 2-3s to fetch the offerings. I’m not sure if this is related to `AppInBackground` always being `true`.

 

Here’s a complete list of debug logs when I open the app

```

2023-02-14 01:15:11.298 30603-30603 Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Debug logging enabled
2023-02-14 01:15:11.298 30603-30603 2Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ SDK Version - 5.7.1
2023-02-14 01:15:11.298 30603-30603 5Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Package name - com.yygg.note.app
2023-02-14 01:15:11.298 30603-30603 mPurchases] - DEBUG     com.yygg.note.app                    D  👤 Initial App User ID - null
2023-02-14 01:15:11.298 30603-30603 Purchases] - DEBUG     com.yygg.note.app                    D  👤 Identifying App User ID: de95dfef-476b-488c-8ea3-a9134e3436a3
2023-02-14 01:15:11.299 30603-30603 yPurchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Deleting old synced subscriber attributes that don't belong to de95dfef-476b-488c-8ea3-a9134e3436a3
2023-02-14 01:15:11.640 30603-30603 ePurchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Starting connection for com.android.billingclient.api.BillingClientImpl@23048b3
2023-02-14 01:15:11.909 30603-30603 Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Billing Service Setup finished for com.android.billingclient.api.BillingClientImpl@23048b3
2023-02-14 01:15:11.909 30603-30603 Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Updating pending purchase queue
2023-02-14 01:15:11.916 30603-30728 -Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Querying purchases
2023-02-14 01:15:11.932 30603-30735 >Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Cleaning previously sent tokens
2023-02-14 01:15:11.932 30603-30735 bPurchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Tokens already posted: ]
2023-02-14 01:15:11.932 30603-30735 pPurchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Saving tokens U]
2023-02-14 01:15:11.933 30603-30735 Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Tokens already posted: []
2023-02-14 01:15:12.144 30603-30705 Purchases] - DEBUG     com.yygg.note.app                    D  Retrieving customer info with policy: CACHED_OR_FETCHED
2023-02-14 01:15:12.148 30603-30705 Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Vending CustomerInfo from cache.
2023-02-14 01:15:12.148 30603-30705 Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Checking if cache is stale AppInBackground true
2023-02-14 01:15:12.149 30603-30687 nPurchases] - DEBUG     com.yygg.note.app                    D  Retrieving customer info with policy: CACHED_OR_FETCHED
2023-02-14 01:15:12.150 30603-30687 ePurchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Vending CustomerInfo from cache.
2023-02-14 01:15:12.150 30603-30687 aPurchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Checking if cache is stale AppInBackground true
2023-02-14 01:15:12.151 30603-30603 3Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ setEmail called
2023-02-14 01:15:12.152 30603-30693 cPurchases] - DEBUG     com.yygg.note.app                    D  Retrieving customer info with policy: CACHED_OR_FETCHED
2023-02-14 01:15:12.153 30603-30693 nPurchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Vending CustomerInfo from cache.
2023-02-14 01:15:12.153 30603-30693 Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Checking if cache is stale AppInBackground true
2023-02-14 01:15:12.172 30603-30705 nPurchases] - DEBUG     com.yygg.note.app                    D  Retrieving customer info with policy: CACHED_OR_FETCHED
2023-02-14 01:15:12.173 30603-30705 ePurchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Vending CustomerInfo from cache.
2023-02-14 01:15:12.174 30603-30705 Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Checking if cache is stale AppInBackground true
2023-02-14 01:15:59.850 30603-30694 Purchases] - DEBUG     com.yygg.note.app                    D  Retrieving customer info with policy: CACHED_OR_FETCHED
2023-02-14 01:15:59.851 30603-30693 ePurchases] - DEBUG     com.yygg.note.app                    D  Retrieving customer info with policy: CACHED_OR_FETCHED
2023-02-14 01:15:59.854 30603-30693 pPurchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Vending CustomerInfo from cache.
2023-02-14 01:15:59.854 30603-30694 sPurchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Vending CustomerInfo from cache.
2023-02-14 01:15:59.854 30603-30693 1Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Checking if cache is stale AppInBackground true
2023-02-14 01:15:59.854 30603-30694 Checking if cache is stale AppInBackground true

```

Hey @william_O,

Thanks for the report - something definitely seems off here. Can you trying backgrounding the app, then foregrounding again and seeing if that toggle works? Trying to figure out what might be causing it, from there we’ll continue investigating.

Were you by chance using an older version of the SDK at some point that wasn’t exhibiting this behavior?


Also, this is my first time integrating the RevenueCat library, so I’ve been using the latest 5.7.1 version since the beginning.


Not sure where my previous comment goes, I’ve replied three comments with debug logs but it says “comment will be shown after someone approves”, 5 days later yet the comment is not shown here.

 

Basically I’ve tried backgrounding the app and then foregrounding it, however, the `AppInBackground` attribute is always true.


Friendly ping on this issue, as this has made our integration and testing with the RevenueCat library extremely difficult


Hey @william_O,

Thanks for the report - something definitely seems off here. Can you trying backgrounding the app, then foregrounding again and seeing if that toggle works? Trying to figure out what might be causing it, from there we’ll continue investigating.

Were you by chance using an older version of the SDK at some point that wasn’t exhibiting this behavior?

Hello, any updates here?


@cody 


Hey @william_O,

Apologies for the delay here. Would you be willing to open a support ticket here so we can investigate further?


Another developer was facing the same issue in 


The issue was a custom WorkManager initialisation. They solved it by making sure the AndroidManifest was only removing the WorkManagerInitializer node:
 

 <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>


Just in case it helps someone else facing this issue


Reply