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("Sandbox" | "Production")?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")
}