revenuecat/ai-toolkit

rc-cancellations-pauses-winback

Use this skill when surfacing cancellation, pause, and winback state on Android with RevenueCat.

查看源码
仓库原始内容

按源仓库内容呈现,保留标题、案例、代码、表格、链接以及原文引用的演示图片。

Cancellations, Pauses, and Winback

Detect cancellation, pause, and winback states on Android by reading CustomerInfo. Most of these events are passive: your app observes them rather than initiates them. Open Google Play's manage screen with managementURL. Look up the pause resume date from the REST API.

Phase 1: Scope

Decide what state you need to surface to the user.

StateSignal in CustomerInfoNotes
Canceled, still has accessentitlement.unsubscribeDetectedAt != null and isActive == trueShow "ends on [expirationDate]"
Billing issue (grace or hold)entitlement.billingIssuesDetectedAt != nullPayment failed, recovery in progress
Pausedentitlement.isActive == false while product is still ownedResume date requires REST API
Active and renewingentitlement.willRenew == trueNormal state

Backend win back campaign segmentation uses the CANCELLATION webhook cancel_reason field (UNSUBSCRIBE, BILLING_ERROR, DEVELOPER_INITIATED, PRICE_INCREASE).

Phase 2: Prepare

Confirm you already have a fetched CustomerInfo from Purchases.sharedInstance.getCustomerInfo(...) or a listener. You do not need to call BillingClient.queryPurchasesAsync with setIncludeSuspendedSubscriptions(true). RevenueCat resolves pause state from the server side subscription state.

Rules:

  • managementURL is already Uri?. Pass it straight to the Intent. Do not call Uri.parse(url.toString()).
  • Do not compute access manually from expirationDate. Read isActive and willRenew.
  • Pause resume date is not in the SDK. Fetch it from /v1/subscribers/{app_user_id} in your backend.

Phase 3: Execute

Detect cancellation with remaining access

kotlin
val entitlement = customerInfo.entitlements["pro_access"]
if (entitlement?.unsubscribeDetectedAt != null && entitlement.isActive) {
    entitlement.expirationDate?.let { expiry ->
        showCancellationBanner(expiry)
    }
}

unsubscribeDetectedAt is set when RevenueCat receives the SUBSCRIPTION_CANCELED RTDN. isActive stays true until the billing period ends.

Detect pause

kotlin
val entitlement = customerInfo.entitlements["pro_access"]
val hasAccess = entitlement?.isActive == true
// When paused, isActive == false. Pause resume date is not in the SDK.

Open the subscription management screen

kotlin
customerInfo.managementURL?.let { url ->
    startActivity(Intent(Intent.ACTION_VIEW, url))
}

managementURL is typed as Uri?. Use it directly. Wrapping it with Uri.parse(url.toString()) is redundant and error prone.

Look up pause resume date via REST

From your backend, call the subscribers endpoint and read paused_expiration_time_ms on the subscription:

bash
curl -H "Authorization: Bearer $RC_SECRET_API_KEY" \
  https://api.revenuecat.com/v1/subscribers/$APP_USER_ID

The subscription object contains paused_expiration_time_ms when paused. Expose this to your client through your own endpoint.

Resubscribe before expiry

Google's resubscribe before expiry flow fires SUBSCRIPTION_RESTARTED. RevenueCat clears unsubscribeDetectedAt and sets willRenew = true. No extra code required, just re-read customerInfo.

Resubscribe after expiry

A resubscribe after expiry fires a RENEWAL webhook, not INITIAL_PURCHASE. Grant entitlement access on both events in your backend handler.

Phase 4: Verify

CheckHow
Cancellation banner showsCancel in Play Store, pull fresh CustomerInfo, confirm unsubscribeDetectedAt != null and isActive == true
Management deep link opensTap the link, verify Play subscriptions screen opens for the correct product
Pause is reflectedPause in Play Store sandbox, confirm entitlement.isActive == false
Pause resume dateCall /v1/subscribers/{id}, confirm paused_expiration_time_ms is present
Win back acceptedAccept a Play configured win back offer, confirm the purchase surfaces as a normal subscription in CustomerInfo

Notes

  • Deferral and revocation are done through the Google Play Developer API (purchases.subscriptionsv2.defer, purchases.subscriptionsv2.revoke) from your backend. RevenueCat processes the resulting RTDN and updates CustomerInfo automatically.
  • Win back campaigns need no SDK code. They are configured in Play Console or the RevenueCat dashboard.
  • RevenueCat does not currently emit a dedicated pause webhook. Pause state appears in CustomerInfo once the Google Play RTDN is processed.

References

来自同一仓库

更多 Skills

全部 Skills
revenuecat
社区

integrate-revenuecat

End-to-end RevenueCat integration — sets up the dashboard side via the RevenueCat MCP or the rc CLI (project, app, public API key) and installs/configures the Purchases SDK in the app. Use when the user asks to add RevenueCat, hook up RevenueCat, add subscriptions or in-app purchases to an app, integrate Purchases, install the RevenueCat SDK, set up a RevenueCat API key, configure Purchases on launch, or set up a brand new RevenueCat integration on iOS, Android, Kotlin Multiplatform, Flutter, or

安装量
2
GitHub Stars
73
最近更新
10月14日
revenuecat
社区

rc-subscriptions

Use this skill when modeling subscriptions through RevenueCat's object model on Android. Covers Offerings, Packages, StoreProduct, SubscriptionOption, PricingPhase, and how they map to Google Play's Subscription, Base Plan, and Offer hierarchy.

安装量
1
GitHub Stars
73
最近更新
10月14日
revenuecat
社区

revenuecat-app-valuation

Use this skill when the user asks how much their app is worth, what they could sell their app for, how app valuations or acquisitions work, or how to prepare a subscription app for sale/exit.

安装量
1
GitHub Stars
73
最近更新
10月14日
revenuecat
社区

revenuecat-billing

Use when the user asks about their RevenueCat plan, billing, their RevenueCat invoices, or how much they will have to pay RevenueCat.

安装量
1
GitHub Stars
73
最近更新
10月14日