Skip to main content

Overview

Push notifications require linking each user to a unique identifier (app_user_id) that persists across sessions and devices. This identifier connects OneSignal, RevenueCat, and your backend database. The same app_user_id must be used consistently across all services to ensure users receive the correct notifications.

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:
Important: The setonesignalplayerid:// protocol must be called on every app launch, not only during first install. Users who were active before push notifications were implemented will not trigger login flows again. This is the only opportunity to sync their identity to OneSignal.

User Login

When a user authenticates, the backend determines whether to claim the current identity or recover an existing one.

User Logout

On logout, generate a new anonymous identifier. Do not reuse the device’s install_id to prevent identity collision between users on shared devices.

Push Permission

Automatic Mode (Default)

When Manual Push Permission is disabled in Despia settings, the permission prompt displays automatically on first launch. No additional code is required.

Manual Mode

Enable Manual Push Permission in Despia settings to control when the prompt appears:

Backend Implementation

Send Push Notification

Single User

Multiple Users

All Users


User Registration Endpoint


User Login Endpoint

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

User-to-User Messaging

For direct messaging features, push notifications serve as a fallback when the recipient is not actively using the app. For real-time messaging, consider dedicated services such as Stream or XMPP.

Database Schema


Offline Retry Queue

Process queued identity syncs on app launch:

Protocol Reference