iOS - Handle errors

In this topic we describe how you can handle most of the SKError's errors e.g.: SKErrorPaymentCancelled, SKErrorInvalidOfferIdentifier, SKErrorUnknown, etc.

Adapty SDK has its own wrapper for all kinds of errors, called AdaptyError. Basically, every error returned by an SDK is AdaptyError. It has two useful properties: originalError and adaptyErrorCode, described below.

originalError contains an original error in case you need the original one to work with. Can be SKError, NSError or just general Swift Error. This property is optional since some errors can be generated directly by SDK, like inconsistent or missing data, and won't have the original error around which the wrapper was initially built.

adaptyErrorCode can be used to handle common issues, like:

  • invalid credentials
  • network errors
  • cancelled payments
  • billing issues
  • invalid receipt
  • and much more

It's pretty easy to check the error for specific codes and react to them accordingly.

Adapty.makePurchase(product: product) { result in
    if result.error?.adaptyErrorCode == .paymentCancelled {
        // purchase was cancelled
        // you can offer discount to your user or remind them later

StoreKit errors

unknown0Error code indicating that an unknown or unexpected error occurred.
clientInvalid1This error code indicates that the client is not allowed to perform the attempted action.
paymentCancelled2This error code indicates that the user canceled a payment request.
No action is required, but in terms of the business logic, you can offer a discount to your user or remind them later.
paymentInvalid3This error indicates that one of the payment parameters was not recognized by the App Store.
paymentNotAllowed4This error code indicates that the user is not allowed to authorize payments.
storeProductNotAvailable5This error code indicates that the requested product is not available in the store.
cloudServicePermissionDenied6This error code indicates that the user has not allowed access to Cloud service information.
cloudServiceNetworkConnectionFailed7This error code indicates that the device could not connect to the network.
cloudServiceRevoked8This error code indicates that the user has revoked permission to use this cloud service.
privacyAcknowledgementRequired9This error code indicates that the user has not yet acknowledged Apple’s privacy policy.
unauthorizedRequestData10This error code indicates that the app is attempting to use a property for which it does not have the required entitlement.
invalidOfferIdentifier11The offer identifier is not valid. For example, you have not set up an offer with that identifier in the App Store, or you have revoked the offer.
Make sure you set up desired offers in AppStore Connect and pass a valid offer identifier.
invalidSignature12This error code indicates that the signature in a payment discount is not valid.
missingOfferParams13This error code indicates that parameters are missing in a payment discount.
invalidOfferPrice14This error code indicates that the price you specified in App Store Connect is no longer valid. Offers must always represent a discounted price.
noProductIDsFound1000This error indicates that none of the products in the paywall is available in the store.
If you are encountering this error, please follow the steps below to resolve it:

1. Check if all the products have been added to the Adapty Dashboard.
2. Ensure that the Bundle ID of your app matches the one from Apple Connect.
3. Verify that the product identifiers from the app stores match the ones you have added to the Dashboard. Please note that the identifiers should not contain Bundle ID unless it is already included in the store.
4. Confirm that the app paid status is active in your Apple tax settings. Ensure that your tax information is up-to-date and your certificates are valid.
5. Check if a bank account is attached to the app, so it can be eligible for monetization.
6. Check if the products are available in all regions.

Also, ensure that your products are in “Ready to Submit” state.
noProductsFound1001This error indicates that the product requested for purchase is not available in the store.
productRequestFailed1002Unable to fetch available products at the moment.
cantMakePayments1003In-app purchases are not allowed on this device.
noPurchasesToRestore1004This error indicates that Google Play did not find the purchase to restore.
cantReadReceipt 1005There is no valid receipt available on the device. This can be an issue during sandbox testing.
In the sandbox, you won't have a valid receipt file until you actually make a purchase, so make sure you do one before accessing it. During sandbox testing also make sure you signed in on a device with a valid Apple sandbox account.
productPurchaseFailed1006Product purchase failed.
missingOfferSigningParams1007This error indicates issues with Adapty integration or with offers.
Refer to the Configure App Store integration and to Offers for details on how to set them up.

Network errors

notActivated2002You need to properly configure Adapty SDK by Adapty.activate method.
badRequest2003Bad request.
serverError2004Server error.
networkFailed2005The error indicates issues with the network connection.
decodingFailed2006This error indicates that response decoding failed.
encodingFailed2009This error indicates that request encoding failed.
missingURL2010The requested URL is nil.

General errors

analyticsDisabled3000We can't handle analytics events, since you've opted it out.
wrongParam3001This error indicates that some of your parameters are not correct do match the constraints.
activateOnceError3005It is not possible to call .activate method more than once.
profileWasChanged3006The user profile was changed during the operation.
persistingDataError3100It was an error while saving data.
operationInterrupted9000This operation was interrupted by the system.

What’s Next