Skip to main content

SDK Reference - getActiveProducts

React native
Flutter
Swift
Kotlin

The getActiveProducts method retrieves all subscriptions or non-consumables owned by the user. If your app includes subscription sales, this method is essential for checking whether the user has an active subscription.

However, if you synchronize your server with IAPHUB using webhooks, you can directly query your server instead, eliminating the need for this method.

By default, the getActiveProducts method only returns subscriptions with an 'active' or 'grace_period' state.
If the includeSubscriptionStates option is specified, you can also retrieve subscriptions in a 'paused' or 'retry_period' state. This option can be useful if you need to display a message regarding these states.

info

If the request fails due to a network issue, the method returns the latest data cached (if available) with no expired subscription; otherwise, an error is thrown.

info

If an active product is returned by the IAPHUB API, but the product SKU cannot be loaded (due to Apple/Google not returning it), the product will still be returned. However, only the properties coming directly from the API will be included. Properties such as localizedTitle, localizedDescription, localizedPrice, price, currency, etc., will not be returned in this case.

Example

var activeProducts = await Iaphub.getActiveProducts();
React Native
Flutter
Swift
Kotlin

Parameters

ObjectOptions
String[]Include filtered subscription states

Response

Array
Object
StringIAPHUB product ID
typeValues
StringProduct type
StringProduct sku
NumberPrice amount
StringPrice currency
StringLocalized product price (Ex: '$12.99')
StringLocalized product title from IAPHUB if available; otherwise, the title from Apple or Google
StringLocalized product description from IAPHUB if available; otherwise, the title from Apple or Google.
Only available if the product belongs to a group
StringIAPHUB group ID
StringName of the product group created on IAPHUB
Only available if the product has associated metadata
ObjectProduct metadata
StringIAPHUB purchase ID
StringPurchase date
platformValues
StringPlatform
BooleanIndicates if the purchase was made in the sandbox environment (testing)
BooleanIndicates if the purchase was made using a promo code
StringPromo code (Android: only available for subscriptions vanity codes, not available for one time codes) (iOS: the value is the offer reference name)
StringAndroid purchase token
Only available for a subscription
StringDuration of the subscription cycle specified in the ISO 8601 format
ArrayOrdered list of the subscription intro phases
Array element
typeValues
StringIntro phase type
NumberIntro phase price
StringIntro phase currency code (Ex: 'USD')
StringIntro phase localized price (Ex: '$2.99')
NumberNumber of cycles of the intro phase
StringDuration of a cycle specified in the ISO 8601 format
StringSubscription expiration date
StringSubscription original purchase id
StringIndicates if the subscription will renew automatically
BooleanIndicates if the subscription is shared by a family member (iOS subscriptions only).
StringSubscription product id of the next renewal (only defined if different than the current product)
StringSubscription product sku of the next renewal (only defined if different than the current product)
StringCurrent state of the subscription
StringPeriod type of the subscription
StringDate when the subscription will automatically resume after being paused (Android subscriptions only).