Skip to content

Fetch offline entitlement mappings through Remote Config#3817

Draft
rickvdl wants to merge 9 commits into
mainfrom
rickvdl/verified-pem-remote-config
Draft

Fetch offline entitlement mappings through Remote Config#3817
rickvdl wants to merge 9 commits into
mainfrom
rickvdl/verified-pem-remote-config

Conversation

@rickvdl

@rickvdl rickvdl commented Jul 22, 2026

Copy link
Copy Markdown
Member

(Don't merge before backend is ready)

Android equivalent of iOS PR RevenueCat/purchases-ios#7265

Description

Implements fetching the ProductEntitlementMapping through the remote config infrastructure. This will only be done when remote config is enabled. And will still fall back to the existing implementation when remote config is disabled through the kill-switch.

There's still an open question around handling the fallback if the kill-switch is activated later here

@@ -101,23 +109,51 @@ internal class OfflineEntitlementsManager(
fun updateProductEntitlementMappingCacheIfStale(completion: ((PurchasesError?) -> Unit)? = null) {
if (isOfflineEntitlementsEnabled() && deviceCache.isProductEntitlementMappingCacheStale()) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method will fetch the PEM from the legacy implementation only when the remote config one fails / is not available. However it could happen that it is fetched successfully, but remote config is disabled in a later stage.

If we want to tackle this as well I guess we'd have to always fetch it from the legacy system still?

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.47%. Comparing base (0289c99) to head (40b147f).

Files with missing lines Patch % Lines
.../offlineentitlements/OfflineEntitlementsManager.kt 87.75% 0 Missing and 6 partials ⚠️
...otlin/com/revenuecat/purchases/PurchasesFactory.kt 94.11% 0 Missing and 1 partial ⚠️
...rchases/common/remoteconfig/RemoteConfigManager.kt 90.90% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3817      +/-   ##
==========================================
+ Coverage   80.43%   80.47%   +0.03%     
==========================================
  Files         408      409       +1     
  Lines       16890    16953      +63     
  Branches     2467     2479      +12     
==========================================
+ Hits        13586    13643      +57     
  Misses       2342     2342              
- Partials      962      968       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rickvdl
rickvdl force-pushed the rickvdl/verified-pem-remote-config branch from 3cf50d1 to 3df4441 Compare July 23, 2026 07:37

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still reviewing but looking great! Just left some initial comments

@OptIn(InternalRevenueCatAPI::class)
internal class ProductEntitlementMappingResult(
val mapping: ProductEntitlementMapping,
private val useIfCurrent: ((ProductEntitlementMapping) -> Unit) -> Boolean,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm TBH, I'm wondering if we need to be so careful specially for PEM... Note that PEM does not change per user + we would trigger a new fetch immediately after changing the user that would override it, so the window of error is quite narrow. I guess this makes it a bit safer, but just wondering if it's worth the extra complexity TBH...

@rickvdl
rickvdl force-pushed the rickvdl/verified-pem-remote-config branch from 3cf50d1 to 40b147f Compare July 23, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants