product in every example below is a Qonversion Product you created in the dashboard; see Displaying Products to fetch and display them.
Make a purchase
Start a purchase with thepurchase() method (Swift), purchaseWithResult: (Objective-C), or purchase() on Android and the cross-platform SDKs. The method returns a purchase result object; when the purchase succeeds, look up the granted entitlement on result.entitlements.
Handle a purchase result
The purchase method returns a single result object on every platform — it does not throw for a user cancellation or a pending purchase. Inspect the status flags and branch on all four cases:- Success —
isSuccess(isSuccessfulon iOS/Android;IsSuccesson Unity). Grant access; read the granted entitlement fromresult.entitlements. - Canceled by the user —
isCanceled(isCanceledByUseron iOS/Android;IsCanceledon Unity). Do not grant access. - Pending —
isPending(IsPendingon Unity). The transaction is queued and awaiting an external action (for example, Ask to Buy or a deferred payment); do not grant access yet. - Error — none of the above. Handle the error (see Purchase errors).
entitlements map. The values are Qonversion.Entitlement objects.
Purchase errors
When a purchase fails, the SDK returns an error rather than an entitlement. The full list of purchase error codes, their iOSQONErrorCode names, and Android names is on the Handling Errors page. The most common purchase errors and where to fix them:
Restore purchases
When a user switches to a new device, callrestore() so they keep access to premium features. Restoring returns the user’s current entitlements; it does not create a new purchase or charge the user.
Check user entitlements
To check a user’s entitlements separately from a purchase — for example, on app launch — use thecheckEntitlements() method. See Check user entitlements for details.
Consumable in-app purchases
Consumable in-app purchases are not tied to an entitlement, so when you make a consumable purchase you only look at the outcome (success or error), not at entitlements. On success, grant the bonus; on error, do not. The flow is:- The customer initiates the consumable in-app purchase.
- You call the Qonversion purchase method.
- You receive the purchase response:
- Successful response — grant the user the bonus.
- Error — do not grant any bonus.
result.transaction on iOS, result.purchase on Android, result.storeTransaction on the cross-platform SDKs):
Android: choose a specific offer
Android only. The Google Play Billing Library lets you sell a subscription with different offers. Read the available offers fromQProduct.storeDetails, then pass the chosen offer through QPurchaseOptions. This is not available on iOS — App Store offers are selected by StoreKit, not by the SDK.
removeOffer on the purchase options builder:
Android: update a subscription
Android only. Upgrading, downgrading, or changing a subscription on the Google Play Store requires setting the old product and, optionally, a replacement mode through theQPurchaseOptions builder. See the Google Play upgrade/downgrade documentation for details. Subscription updates through this API are not supported on iOS.
WithTimeProration.