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]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).
Native references: Apple · Product.SubscriptionInfo.Status · Google · Sell subscriptions
Common Fields#
| Name | Type | Summary |
|---|---|---|
productId | string | Subscription product identifier |
isActive | boolean | Whether the subscription is currently active |
transactionId | string | Transaction identifier for backend validation |
purchaseToken | string? | JWS token (iOS) or purchase token (Android) for server validation |
transactionDate | number | Transaction timestamp (epoch ms) |
currentPlanId | string? | 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#
| Name | Type | Summary |
|---|---|---|
expirationDateIOS | number? | Expiration timestamp (epoch ms) |
environmentIOS | ("Production" | "Sandbox" | "Xcode")? | StoreKit environment |
daysUntilExpirationIOS | number? | Days until expiration |
renewalInfoIOS | RenewalInfoIOS? | 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")
}