Documentation comes from this release commit, without inheriting newer content. Commit: 371ee4692c.
RC / IAP Monetization — Integration Design
Design + plan for wiring RevenueCat into piano, re-based onto dev's catalog-from-sheet +
entitlements model (post origin/dev merge). Status: DESIGN — approved, pending PO inputs.
Scope: subscription (premium) + No-Ads pack (no_ads) + IAP single-song deals. Date: 2026-06-22.
Decisions taken (design session)
- Live prices — the paywall renders localized prices from
hub.subscription.getOfferings(), not static copy (App Store compliance + currency correctness). - Refresh-based entitlement sync —
hub.subscriptionexposes no live customer-info listener, so RC entitlements are synced to the app on firstensureHubPurchases()configure (getCustomerInfo) and after purchase/restore (both return{ customerInfo, isPremium }). A live listener can be added later for in-session renewal. - RC is the source of truth —
entitlements-store(isPremium,adsRemoved) + owned songs are a cache/mirror of RC entitlements, not hand-set flags. - No-Ads pack → a real RC entitlement
no_ads(RC-first, mirrorspremium). - IAP songs → each IAP song carries an App Store
productIdsourced from a newproductIdcolumn in the catalog Google Sheet (perisIAProw), valuecom.piano.songdeal1/2/3. 1 product = 1 song. - Variant → offering (confirmed): paywall
premium/ post-onboarding →defaultoffering (weekly+yearly);oneTimeOffer→discountoffering (weekly50+yearly50).
1. Product catalog (from PO spec)
RC returns 4 offerings — verified live on-device 2026-06-22 (all products + localized prices load OK; RC side is fully ready):
default—$rc_annual→com.piano.yearly(1.199.000đ) ·$rc_weekly→com.piano.weekly(249.000đ)discount—$rc_annual→com.piano.yearly50(599.000đ) ·$rc_weekly→com.piano.weekly50(119.000đ)iap_noads—iap_noads→com.piano.noadspack(299.000đ)iap_song—song_1/song_2/song_3→com.piano.songdeal1/2/3(29.000đ each)
2. Entitlement model — 3 buckets (mapped to dev's model)
Lock model already exists (packages/catalog/src/lock-rules.ts getSongLockState): VIP/owned →
PLAYABLE; else isPremium→LOCKED_PREMIUM, isIAP→LOCKED_IAP, isAdsUnlock→LOCKED_ADS. Premium
entitlement makes ctx.isVip true → every song resolves PLAYABLE. No lock-rule change needed.
Ad-gating rules
3. Architecture — entitlement sync
RevenueCat lifetime (heap / memory)
react-native-purchases and the native RevenueCat SDK are process-lifetime singletons, not
screen-scoped. Once ensureHubPurchases() runs, the JS module, hub.subscription, and native configure
stay reachable until the app process ends.
Deferred init (so a browsing-only song list can avoid RC until paywall/IAP):
Guest session creation does not call RC — lock UI reads MMKV-hydrated entitlements-store until one of
the paths above runs. The first configure logs [rc] init | reason = … and stores the tag in
the IAP init reason for heap profiling.
entitlements-store needs setPremium(bool) / setAdsRemoved(bool) setters — subscriptions lapse,
so the sync must be able to clear, which dev's grant-only grantPremium()/removeAds() can't.
grantPremiumEntitlement() stays for the VIP library/SDK side-effects (called when premium flips true).
hub.ts already caches isPremiumCached for ad-gating; extend the launch refresh to also (a) cache
isNoAdsCached and (b) push both into entitlements-store. A single syncEntitlementsFromRC() is the
one place that reads customerInfo and writes the store/library.
4. Files to create
src/features/monetization/catalog.ts— typed product catalog (id, kind, offering, entitlement). Pure data + types; single source of truth for product ids. No RN/RC imports.src/features/monetization/entitlements.ts— pure gating helpers from{ isPremium, isNoAds }:shouldShowInterstitial,shouldShowBanner,shouldShowRewarded. Unit-tested next to the file.src/features/monetization/syncEntitlementsFromRC.ts— reads aCustomerInfo, writesentitlements-store+grantPremiumEntitlement/clear. The launch + purchase/restore sync seam.
5. Integration points (dev's actual files → change)
6. Hub change (required for no_ads)
The IAP adapter maps a single premium entitlement. no_ads needs a second entitlement check:
- The app checks
info.entitlements.active["no_ads"]directly in the IAP adapter (the former hub is gone).
→ Checking no_ads via getCustomerInfo() in syncEntitlementsFromRC needs no hub release.
7. Plan (phases)
P1 + P3 start immediately. P2/P4 (no_ads) wait on PO's RC no_ads entitlement. P5 waits on PO's IAP mapping.
Open items / PO
create RC entitlement— NOT needed: non-consumable IAPs (no_adsnoadspack,songdeal*) are read fromcustomerInfo.allPurchasedProductIdentifiers(product-ownership). Onlypremiumsubscriptions need an entitlement (already configured — verify after a test purchase).- IAP songs (P5) — chosen:
Rush E+Passo Bem Solto (Slowed)(2 songs → 2 of the 3songdealproducts;songdeal3reserved). Theiap_songoffering exists (song_1/2/3→songdeal1/2/3). Still needed for P5: the 2 songs' catalog ids, whichsongdeal{1,2}each maps to, and aproductIdcolumn in the Sheet (or a hardcoded 2-entry map). These 2 rows must haveisIAP=truein the Sheet. - Confirm the App Store subs carry the 3-day free-trial intro offer on
weekly/yearly(none on*50) — RC surfaces it via the package intro price.