Question

Android AppInBackground is always true even when app is at foreground

  • 13 February 2023
  • 7 replies
  • 103 views

Userlevel 1
Badge +6

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 [Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ SDK Version - 5.7.1
2023-02-14 01:15:11.298 30603-30603 [Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Package name - com.yygg.note.app
2023-02-14 01:15:11.298 30603-30603 [Purchases] - 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 [Purchases] - 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 [Purchases] - 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 [Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Tokens already posted: []
2023-02-14 01:15:11.932 30603-30735 [Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Saving tokens []
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 [Purchases] - DEBUG     com.yygg.note.app                    D  Retrieving customer info with policy: CACHED_OR_FETCHED
2023-02-14 01:15:12.150 30603-30687 [Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Vending CustomerInfo from cache.
2023-02-14 01:15:12.150 30603-30687 [Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Checking if cache is stale AppInBackground true
2023-02-14 01:15:12.151 30603-30603 [Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ setEmail called
2023-02-14 01:15:12.152 30603-30693 [Purchases] - DEBUG     com.yygg.note.app                    D  Retrieving customer info with policy: CACHED_OR_FETCHED
2023-02-14 01:15:12.153 30603-30693 [Purchases] - 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 [Purchases] - DEBUG     com.yygg.note.app                    D  Retrieving customer info with policy: CACHED_OR_FETCHED
2023-02-14 01:15:12.173 30603-30705 [Purchases] - 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 [Purchases] - DEBUG     com.yygg.note.app                    D  Retrieving customer info with policy: CACHED_OR_FETCHED
2023-02-14 01:15:59.854 30603-30693 [Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Vending CustomerInfo from cache.
2023-02-14 01:15:59.854 30603-30694 [Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Vending CustomerInfo from cache.
2023-02-14 01:15:59.854 30603-30693 [Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Checking if cache is stale AppInBackground true
2023-02-14 01:15:59.854 30603-30694 [Purchases] - DEBUG     com.yygg.note.app                    D  ℹ️ Checking if cache is stale AppInBackground true

```


7 replies

Userlevel 6
Badge +8

Hey @william_O,

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

Userlevel 1
Badge +6

@cody 

Userlevel 1
Badge +6

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?

Userlevel 1
Badge +6

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

Userlevel 1
Badge +6

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.

Userlevel 1
Badge +6

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

Userlevel 6
Badge +8

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?

Reply