Skip to main content

Overview

RevenueCat requires linking each user to a unique identifier (app_user_id) that persists across sessions and devices. This identifier connects RevenueCat, OneSignal, and your backend database. RevenueCat receives the user identity only when launching a paywall via the external_id parameter:

Database Synchronization Requirement

The user must exist in your database before they can make a purchase. When RevenueCat sends a webhook after a purchase, your backend must be able to locate the user to send push notifications.

Successful Flow

Failed Flow (Database Sync Missing)


Identity Resolution

On every app launch, resolve the user’s identity using the following priority:

Implementation

App Startup

Execute this logic on every app launch. Track both identity resolution and database synchronization status before allowing paywall access.

Launch Paywall

Always verify that identity resolution and database synchronization are complete before opening the paywall.
Example usage in a UI component:

Identity Locking

When a user has made purchases, lock their identity to prevent accidental changes that could orphan their purchase history.

Check Subscription Status


Restore Purchases

Provide a restore purchases button for users who need to recover their subscriptions on a new device.

User Login


User Logout


Backend Implementation

Webhook Handler

RevenueCat sends webhooks for subscription events. Your handler must be idempotent and include a safety net for missing users.

Webhook Event Types


User Registration Endpoint


User Login Endpoint

Use row-level locking to prevent race conditions when multiple devices authenticate simultaneously.

Database Schema


Debugging

Use this function to inspect the current identity state:

Common Issues


Protocol Reference