Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

rc-subscription-states

БесплатноБез исполняемых скриптовНе проверен

Use this skill when gating access based on RevenueCat subscription state on Android. Covers reading CustomerInfo, checking entitlement.isActive as the single…

RevenueCatот RevenueCat★ 80 звёзд на GitHub

Об этом скилле

Subscription States

Decide whether a user has access, and drive state aware UI, using CustomerInfo and EntitlementInfo on Android.

Phase 1: Discover

Confirm what you are actually checking before you write code.

  • Which entitlement identifier gates the feature? (for example pro_access)
  • Do you need a plain access boolean, or do you also need to explain why the user has or lacks access (billing issue, canceled but still paid, paused)?
  • Do you need the cached value (fast, possibly stale) or a freshly fetched value (server authoritative)?
  • Are you refreshing UI once on launch, or reacting to live changes (purchase, restore, background refresh)?

If you only need access on/off, you only need isActive. Everything else is optional context.

Phase 2: Plan

Google's eight states versus RevenueCat's boolean

Rolling your own tracker with the Google Play Developer API means mapping eight subscription states and deciding which grant access.

Google state Grants access?
ACTIVE yes
IN_GRACE_PERIOD yes
CANCELED (before expirationDate) yes
ON_HOLD no
PAUSED no
EXPIRED no
PENDING no
PENDING_PURCHASE_CANCELED no

RevenueCat computes this on the backend from the Google SubscriptionPurchaseV2 resource and exposes the result as one field: EntitlementInfo.isActive. You read a boolean instead of implementing the state machine.

What to read, and when

Need Field
Does the user have access right now? entitlement.isActive
Will the subscription renew at period end? entitlement.willRenew
When does paid access end? entitlement.expirationDate
Is this a trial, intro, prepaid, or normal period? entitlement.periodType
Is there a payment problem? entitlement.billingIssueDetectedAt
Has the user canceled but still has time left? entitlement.unsubscribeDetectedAt
Which store issued the entitlement? entitlement.store

Decision rules

  • Gate features on isActive == true. Nothing else.
  • Use billingIssueDetectedAt != null to show a fix payment prompt.
  • Use unsubscribeDetectedAt != null with expirationDate to show a renewal reminder while access is still valid.
  • Use !willRenew (when no billing issue and no explicit cancel timestamp) to show a non renewing notice.

Phase 3: Execute

Read CustomerInfo and check access

val customerInfo = Purchases.sharedInstance.awaitCustomerInfo()
val hasAccess = customerInfo.entitlements["pro_access"]?.isActive == true

awaitCustomerInfo() returns the disk cache immediately, then refreshes from the network in the background. Entitlement checks stay fast, even offline.

Force a fresh fetch when you must

Use this after a server side grant (for example, a support agent issued a promo).

val fresh = Purchases.sharedInstance.awaitCustomerInfo(
    fetchPolicy = CacheFetchPolicy.FETCH_CURRENT
)

Drive state aware UI

isActive gates access; the other fields explain context.

fun updateUI(entitlement: EntitlementInfo?) {
    if (entitlement != null && !entitlement.isActive && entitlement.billingIssueDetectedAt != null) {
        // Account hold, or an expiry after a billing issue that was never resolved. See rc-payment-recovery.
        showAccountHoldScreen(); return
    }
    if (entitlement == null || !entitlement.isActive) {
        showSubscribeScreen(); return
    }
    showPremiumContent()
    when {
        entitlement.billingIssueDetectedAt != null -> showBillingIssueWarning()
        entitlement.unsubscribeDetectedAt != null ->
            entitlement.expirationDate?.let { showExpiryNotice(it) }
        !entitlement.willRenew -> showNonRenewingNotice()
    }
}

Messaging guide by signal

Signal on an active entitlement Message to show
billingIssueDetectedAt != null Payment problem, update method
unsubscribeDetectedAt != null Access ends on expirationDate
willRenew == false (no other signal) Will not renew this period
periodType == TRIAL or INTRO Trial or intro pricing in effect

Identify the user for multi device

val result = Purchases.sharedInstance.awaitLogIn("your_user_id")
val customerInfo = result.customerInfo
val createdNewUser = result.created

awaitLogIn() merges anonymous purchases with the identified user. logOut() starts a fresh anonymous session.

Phase 4: Verify

Listen for CustomerInfo updates

Register a listener so UI reacts to purchases, restores, and background refreshes without manual polling.

Purchases.sharedInstance.updatedCustomerInfoListener =
    UpdatedCustomerInfoListener { info ->
        val active = info.entitlements["pro_access"]?.isActive == true
        updateAccessGate(active)
    }

Setting the listener immediately delivers the cached CustomerInfo if one exists. On a first launch with no cache it fires only after the first fetch,

Полный SKILL.md на GitHub

Установить rc-subscription-states в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл rc-subscription-states?

Use this skill when gating access based on RevenueCat subscription state on Android. Covers reading CustomerInfo, checking entitlement.isActive as the single source of truth for access, and drilling into willRenew, periodType, and expirationDate when deeper logic is needed.

Как установить скилл rc-subscription-states?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл rc-subscription-states запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить rc-subscription-states с