Skip to main content
Infrastructure

Handling StoreKit Errors

List of SKErrors (SKErrorDomain 0, SKError.Code, NSURLErrorDomain, and more), and how to handle StoreKit errors.

Sam Mejlumyan

Sam Mejlumyan

October 5, 20206 min read
StoreKit Errors

Hi, Sam here. Today, I want to talk about something all too familiar for developers working with in-app purchases—StoreKit errors.

Errors are inevitable, especially when working with third-party services like StoreKit. That’s why having a solid error-handling strategy is crucial especially when working with a library like StoreKit. I often refer to StoreKit as to a black-box where anything can happen. In this article, I’ll show you how to handle failed transactions using StoreKit and provide users with the right feedback when errors occur.


Storekit errors are a major part of managing payments, and failing to handle them properly can quickly turn into a negative user experience. If your app doesn’t manage these errors correctly, it could lead to poor retention rates or even uninstalls.

storekit error message
storekit error message

NSError Overview

I’d like to start by giving a quick reminder of how NSError works, as we will work with it in this article. Any error that happens on iOS includes the error domain, a domain-specific error code, and additional information specific to the application. So, for us, the most important fields are:

Variety of SKErrors

Errors associated with payments, store products, and cloud services occur under the domain model SKErrorDomain and error codes SKError.Code. The entire list of errors includes more than 15 options; you can find them below and in the documentation. In addition to SKErrorDomain errors, network problems may occur in the NSURLErrorDomain model. Let’s take a look at how to handle them all.

There are a lot of types of errors, so I‘d recommend dividing them into several groups:

  • external, which cannot be influenced in any way, for example, network problems
  • request errors such as incorrect product ID
  • user-side errors such as canceling an operation or an unverified account

Handling StoreKit errors

For error handling, we need to implement two methods of the SKRequestDelegate delegate.optional func request(_ request: SKRequest, didFailWithError error: Error) CopyThis is an optional method that receives errors from SKRequest. It is essential to keep in mind that when these errors occur, (void) requestDidFinish: (SKRequest *) request will not be called.The second point of failure is transaction processing; here, errors are pretty varied and can be associated with both when the user cancels the operation and when rights have been restricted, such as parental controls. To be able to receive errors when working with transactions, it is necessary to process the the transaction status SKPaymentTransactionStateFailed separately. To get these events, you should use a skpaymenttransactionobserver.You should handle paymentQueue(_:updatedTransactions:) and all states of these transactions.However, in this article, we will explore .failed states. As Apple mentions in its official documentation, you should obtain the error field from this transaction and then check the list of SKErrorDomain errors.

How to handle SKErrors:

Let’s take a look at all the possible cases of StoreKit errors.

.unknownSKErrorUnknown code 0

This error SKErrordomain 0 return usually happens when an unknown or unexpected error has occurred. Usually, there is no need to take any action on the developers side, but here are a few recommendations to check:

  • Check the LocalizedDescription property of the error object.
  • If the error appeared during the testing, try logging out or try it with a new test user.
  • The problem might be on the user’s account side, so it is worth asking the users to check and see if anyone gets back to you with more information.

.SKErrorClientInvalid code 1

This error is displayed when someone without the required permissions tries to perform the action. No action is needed to be done on your side. However, it is possible to try and show an automated notification with a message related to the action such as: “due to x,y,z you are not allowed to perform the action. Please, change your account or device”.

.SKErrorPaymentCancelled code 2

This error code indicates that the user canceled a payment request. No action is needed from your side, however, you could try to look at the user’s behavior to find the right trigger to encourage the user to complete the payment in the future – such as an offer or triggered email that talks about the value of your app. The best reaction to this error would be to catch the event and send the user an automated notification with a discount offer or something else of value to try and encourage them to continue using your app.

.SKErrorPaymentInvalid code 3

This error shows that the payment was not processed correctly due to an issue with the billing – Error code indicating that one of the payment parameters wasn’t recognized by the App Store, card expiration or not enough funds. Try to check whether the billing issue is related to card expiration and if so, the best idea is to catch this error, and send an automated notification or email with a reminder to your user.

.SKErrorPaymentNotAllowed code 4

An error code that indicates that the user is not allowed to authorize payments. And how you deal with this? Inform the user that payments are disabled, and direct them to the appropriate settings to enable purchases.

.SKErrorStoreProductNotAvailable code 5

This error might happen when your user tries to purchase a product that is unavailable in their region. Check the product availability via SKStorefront. You may want to display a message like: “This product is not available in your region. Stay tuned for updates!”

.SKErrorCloudServicePermissionDenied code 6

This error occurs when the user denies access to Cloud services, which are sometimes required for certain purchases. The best practice here is to guide users to adjust their permissions if Cloud services are required for the app’s full functionality.

Wrapping Up

Handling StoreKit errors properly is key to ensuring a seamless user experience, especially when dealing with in-app purchases. By carefully managing errors, not only can you keep users engaged, but you can also reduce frustration and improve retention rates. Bookmark this page to return to it when needed and remember — every error is an opportunity to communicate with your users and potentially turn the situation around.

As always, stay tuned for more tips and get in touch with me if you need any app-related hep.

Sam Mejlumyan

Sam Mejlumyan

CEO of Qonversion

Sam is an entrepreneur and CEO of Qonversion – the in-app purchase platform which processes over $1 billion tracked revenue yearly. With deep expertise in subscription management and a passion for driving data-driven strategies.

Share:

Ready to optimize your subscriptions?

Start using Qonversion today and see the difference.