Subscriptions Validation

Check user subscription status

Qonversion SDK provides a method for checking user subscription status, so you can provide access to premium features to active subscribers and block access and provide subscription or purchase options to others.

Check user subscription

Most app users have only one subscription. For that reason, you can get the first item from activeProducts and check its status.

Swift
Objective-C
Swift
Qonversion.checkUser({ result in
​
guard let activeProduct = result.activeProducts.first else {
// Flow for users without any active subscription
return
}
if activeProduct.state == .trial, activeProduct.status == .active {
// Flow for users with active subscription
}
}) { _ in }
Objective-C
[Qonversion checkUser:^(QonversionCheckResult * _Nonnull result) {
RenewalProductDetails *activeObject = result.activeProducts.firstObject;
if (activeObject) {
} else {
// Flow for users without any active subscriptions
}
} failure:^(NSError *error) {
}];

Qonversion.checkUser returns QonversionCheckResult based on server-side validated data. Be sure that you have provided the correct App-Specific Application shared secret in Qonversion application settings prior to using this method. For more details on providing the App-Specific Application shared secret, see here.

​

The full list of QonversionCheckResult properties:

Property

Description

timestamp

Original Server response time

environment

The environment for which the receipt was generated

activeProducts

Array with RenewalProductDetail

Only active user products, doesn't include non expired products that were refunded

allProducts

All subscription based products

RenewalProductDetails fields:

Property

Description

state

Subscription status:

  • trial – still in trial period

  • subscription – active subscription not in trial period

status

Renewal status, could be one of these:

  • canceled

  • active

  • refunded

productID

App Store Product ID

originalTransactionID

App Store Original Transaction ID

createdAt

Timestamp when purchase was created in Qonversion database

purchasedAt

Original purchase timestamp, received from Apple

expiresAt

Subscription expiration timestamp

expired

bool; true if subscription expired; false if subscription is still active

billingRetry

bool; true if subscription in billing retry state;