SDK error · code 0

unknownError (error code 0): Unknown error

What it means

unknownError (code 0) is the SDK's catch-all: a failure it could not classify, such as a StoreKit or Play Billing error it has no mapping for, or an exception with no better match. The real cause sits in the underlying error and the debug log, so read those first. Do not grant access, and retry only when the customer starts the action again.

Code

0

iOS (Swift)

ErrorCode.unknownError

Android (Kotlin)

PurchasesErrorCode.UnknownError

Causes

Why the SDK returns unknownError

  • iOS StoreKit 1: an SKError code the SDK does not map. The SKError mapping covers a fixed list, and anything else, including undocumented codes, falls through to unknownError.
  • iOS StoreKit 2: a StoreKitError or Product.PurchaseError case that is newer than the SDK. The StoreKit mapping sends every unknown case here.
  • Android: an exception that is not a network, security or signature failure becomes unknownError, and so does any Play Billing response code outside the known list (errors.kt).
  • The backend answered with code 0, which the SDK reads as "we don't know what happened" (BackendErrorCode.swift).
  • Flutter: PurchasesErrorHelper.getErrorCode returns unknownError when the platform error code is outside the enum's range.

Fix

How to fix unknownError

  1. 01

    Read the underlying error

    On iOS, read NSUnderlyingErrorKey and readable_error_code from userInfo. On Android, read error.underlyingErrorMessage. They name the StoreKit, Play or backend error that the SDK could not map.

  2. 02

    Turn on debug logs

    Set Purchases.logLevel = .debug on iOS or Purchases.logLevel = LogLevel.DEBUG on Android, reproduce the failure, and read the lines before the error.

  3. 03

    Check for a backend code

    If rc_backend_error_code is in userInfo (iOS), the failure came from the server and the number says which. Look it up in the table on this site's error list.

  4. 04

    Update the SDK

    A StoreKit or Play Billing error that is new to the OS can be unmapped in an old SDK. Update to the latest SDK release and test again.

In your app

How to handle it in code

  • Do not grant access. Nothing in the error says the purchase succeeded.
  • Do not retry automatically. Let the customer tap the button again, because an unknown failure may repeat.
  • Show a neutral message such as "Something went wrong, please try again", and log the underlying error so you can classify it later.
Match the errorSwift · Kotlin
// Swift
do {
  let result = try await Purchases.shared.purchase(package: package)
} catch let error as ErrorCode where error == .unknownError {
  // handle unknown error
}

// Kotlin
if (error.code == PurchasesErrorCode.UnknownError) { /* ... */ }

On RevenueDot: RevenueDot always answers failures with a JSON body that has a numeric code, so a server failure reaches the SDK as a backend error (unknownBackendError at worst), not as unknownError. See what RevenueDot's API errors mean.

FAQ

unknownError: questions people ask

What does unknownError mean in RevenueCat?

It is the SDK's fallback for a failure it cannot classify. The cause is in the underlying error: read NSUnderlyingErrorKey on iOS or underlyingErrorMessage on Android, and turn on debug logs.

Is unknownError a RevenueCat server problem?

Usually not. Server problems arrive as backend errors with their own codes (unknownBackendError, storeProblemError, and so on). unknownError mostly comes from an unmapped StoreKit, Play Billing or system error on the device.

How do I check for unknownError in React Native and Flutter?

In React Native, compare error.code with PURCHASES_ERROR_CODE.UNKNOWN_ERROR. In Flutter, convert the PlatformException with PurchasesErrorHelper.getErrorCode(e) and compare the result with PurchasesErrorCode.unknownError.

Get started

Keep the RevenueCat SDK. Change the backend.

RevenueDot answers the same SDK calls with the same error codes. Start free on RevenueDot Cloud, free up to $10,000 a month in tracked revenue.

Already have an account? Sign in · Prefer your own servers? Self-host free