Use this page with AI

Copy this into your coding assistant and add your request.

Read https://openiap.dev/docs/types/active-subscription and https://openiap.dev/llms.txt. Follow the reading instructions, detailed reference, and linked guides relevant to my task before making changes.
Inspect my existing project and reuse its framework and conventions. Ask me for missing product decisions. Implement the requested behavior and run the applicable checks.
Show the working result, the commands and actual test results, and any remaining limitations. Keep your explanation brief.

My request: [describe what customers should be able to do]
See an example request →

ActiveSubscription

ActiveSubscription#

Represents an active subscription returned by getActiveSubscriptions(). Provides a unified view of subscription status across platforms.

Cross-platform shape returned by getActiveSubscriptions. iOS: derived from Transaction.currentEntitlements filtered to subscription products (Apple docs). Android: derived from BillingClient.queryPurchasesAsync(SUBS) (Google docs).

Common Fields#

NameTypeSummary
productIdstringSubscription product identifier
isActivebooleanWhether the subscription is currently active
transactionIdstringTransaction identifier for backend validation
purchaseTokenstring?JWS token (iOS) or purchase token (Android) for server validation
transactionDatenumberTransaction timestamp (epoch ms)
currentPlanIdstring?Unified plan identifier. On Android: basePlanId (e.g., "premium"). On iOS: productId (e.g., "com.example.premium_monthly"). ⚠️ Android: May be inaccurate for multi-plan subscriptions because Google Play Billing's Purchase object does not expose basePlanId directly — it has to be inferred. See limitation.

Platform-Specific Fields#

iOS Fields#

NameTypeSummary
expirationDateIOSnumber?Expiration timestamp (epoch ms)
environmentIOS("Production" | "Sandbox" | "Xcode")?StoreKit environment
daysUntilExpirationIOSnumber?Days until expiration
renewalInfoIOSRenewalInfoIOS?Subscription renewal details

Usage Example#

swift
// Check for pending upgrades
if let pendingProductId = subscription.renewalInfoIOS?.pendingUpgradeProductId {
    print("Upgrade pending to: \(pendingProductId)")
}

// Check if subscription is cancelled
if subscription.renewalInfoIOS?.willAutoRenew == false {
    print("Subscription will not auto-renew")
}