SDK error · code 14

invalidAppUserIdError (error code 14): Invalid app user ID

What it means

invalidAppUserIdError (code 14) means the app user ID is empty, too long, or missing from the device. The backend answers 7220 or 7256, and the SDK raises it when logIn gets an empty or blank ID. Pass a non-empty string of at most 100 characters to logIn, never an empty string, and make sure your own user ID is loaded before you call it.

Code

14

iOS (Swift)

ErrorCode.invalidAppUserIdError

Android (Kotlin)

PurchasesErrorCode.InvalidAppUserIdError

Causes

Why the SDK returns invalidAppUserIdError

  • logIn was called with an empty or whitespace-only ID. The iOS SDK trims the ID first, and the Android SDK checks for a blank one (IdentityManager.swift).
  • The backend answered 7220 (empty app user ID) or 7256 (invalid app user ID), which both SDKs map here (BackendErrorCode.swift).
  • iOS: the stored app user ID was missing from user defaults. The SDK notes this can happen if user defaults are removed by hand or the OS deletes entries when storage runs low (ErrorUtils.swift).
  • The ID your code passes is null or an unloaded value, for example a user ID read before sign-in finished.
  • On RevenueDot, an ID longer than 100 characters.
Backend codeMeaning
7220Empty app user ID.
7256Invalid app user ID.

Fix

How to fix invalidAppUserIdError

  1. 01

    Guard the call

    Call logIn only when you have a real, non-empty user ID. Wait for your own sign-in to finish first.

  2. 02

    Keep the ID short

    Use a stable ID of at most 100 characters, such as your database user ID. Do not use an email address that can change, and never a value that is shared between people.

  3. 03

    Do not log in with the anonymous ID

    Leave anonymous users anonymous. Call logIn only after real sign-in, and logOut on sign-out.

  4. 04

    Recover a lost stored ID

    If the SDK lost its stored ID, call logIn again with your own ID so the customer maps back to the right customer record.

In your app

How to handle it in code

  • Do not retry with the same value. Fix the ID first.
  • This is a bug in your sign-in flow, not something the customer can fix. Show a generic error and log the value's shape (empty, length), not the value.
  • Do not grant access from the error.
Match the errorSwift · Kotlin
// Swift
do {
  let result = try await Purchases.shared.purchase(package: package)
} catch let error as ErrorCode where error == .invalidAppUserIdError {
  // handle invalid app user id
}

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

On RevenueDot: RevenueDot answers HTTP 400 with code 7220 when app_user_id is empty or longer than 100 characters. Anonymous IDs start with $RCAnonymousID:, and logging in moves purchases made as an anonymous user to the new ID. See Why is my entitlement not active?.

FAQ

invalidAppUserIdError: questions people ask

What is a valid app user ID?

A non-empty string. On RevenueDot it can be at most 100 characters. Use your own stable user ID, not an email that can change.

Why does logIn fail with invalidAppUserIdError?

The ID you passed is empty or only whitespace, or the server rejected it as invalid. Check that your user ID is loaded before you call logIn.

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

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

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