Active Subscriptions
Active subscription checks answer the runtime question: which paid plan should this user receive right now? OpenIAP keeps that workflow consistent across Apple, Google Play, Meta Horizon, Amazon Fire OS, and Vega OS by returning ActiveSubscription objects keyed by store product identity instead of requiring app code to branch on each store's subscription-group model.
Recommended Flow#
- Configure subscription products in each store with stable product IDs/SKUs for every plan you need to grant.
- Fetch the product catalog with
fetchProductsbefore purchase so the SDK knows the store product type and available offers. - Call
requestPurchasewith the selected subscription SKU or offer. - On app launch, after purchase updates, and after restore, call
getActiveSubscriptionsorhasActiveSubscriptionswith the subscription IDs your feature accepts. - For server-backed access, verify with IAPKit or your store server API and treat the server result as authoritative.
Do not build entitlement logic around a universal subscription group field. Stores expose group information differently. The stable cross-store fields are productId, currentPlanId when available, and the store purchase token/transaction ID for verification.
API Usage#
The same app code works for the native packages and framework SDKs. Pass the product IDs/SKUs that unlock the feature; OpenIAP filters the active store entitlements and returns the matching subscriptions.
import OpenIAP
let premiumIds = [
"dev.hyo.martie.premium",
"dev.hyo.martie.premium_year"
]
let active = try await OpenIapModule.shared.getActiveSubscriptions(premiumIds)
let canUsePremium = active.contains { $0.isActive }
for subscription in active {
print(subscription.productId) // Store product ID
print(subscription.currentPlanId) // iOS product ID
print(subscription.transactionId) // Verify on your server/IAPKit
}
let hasPremium = try await OpenIapModule.shared.hasActiveSubscriptions(premiumIds)Store Behavior#
Apple App Store
Apple has a real subscription group in App Store Connect, and StoreKit transactions expose subscriptionGroupID. OpenIAP keeps that platform detail on iOS purchase objects as subscriptionGroupIdIOS.
For active entitlement checks, use productId and currentPlanId. On iOS, currentPlanId is the current StoreKit product ID, so multiple subscription groups can return multiple active entries without being merged together.
- Upgrade/downgrade rules still depend on Apple subscription group ordering.
renewalInfoIOS.autoRenewPreferenceshows the product that will renew next.getActiveSubscriptionsreads current StoreKit entitlements and filters by product ID.
Entitlement Design#
For app UI, map your feature to an accepted set of product IDs. For backend authorization, send purchaseToken / transactionId to your server and verify with the relevant store API or IAPKit. The client-side active subscription list is useful for immediate UI state, but the server should own durable entitlement decisions.
const premiumProductIds = new Set([
'dev.hyo.martie.premium',
'dev.hyo.martie.premium_year',
]);
function grantsPremium(subscription: ActiveSubscription) {
return subscription.isActive && premiumProductIds.has(subscription.productId);
}