Skip to main content
This reference covers the RevenueCat bridge in the Despia V3 native runtime. Enable RevenueCat and rebuild both native apps before using these commands. Follow the setup guide first.

Call the native bridge

Register callbacks before calling despia(). Each response also updates a global variable. The callback receives a JavaScript object, so do not call JSON.parse() on it. Use the command spellings below and encode each query value with encodeURIComponent(). These URLs must go through despia() or a real link/navigation. fetch('revenuecat://...') is not a bridge call. Send one command at a time and wait for its response before sending the next; consecutive navigations can replace each other.

Commands

Purchase, paywall, Customer Center, and redemption commands require purchasing to be available in the native build. Catalog and identity reads do not make a purchase. The older Android offerings command also checks the purchasing license; use products for the catalog envelope.

Response envelope

Catalog, customer, and identity responses share these fields:
platform is ios or android. user is the current RevenueCat App User ID. registered means the RevenueCat identity is not anonymous; it does not authenticate the user with your own backend. project can be null when it is not configured. On failure, check ok: false, code, and error before reading command-specific fields.

Detect capabilities on older builds

bridge: 2 identifies support for whoami and for purchases/paywalls using the current user when external_id is omitted. Read it from a catalog or customer response before using those features. An absent value means the app may be on an older runtime.
Do not probe an unknown command on an old build: old runtimes may route it through the purchase path. Keep an older integration’s required external_id until the new native build is installed.

Load products and purchase prices

The catalog adds current (the current offering ID or null), offerings (offering objects), and products (a flat product list, deduplicated across offerings). This excerpt shows one offering:
The example shows a package’s product; the actual flat products array contains the same product objects. Display priceString, not a hardcoded price or a currency symbol combined with price. Subscription periods such as P1M and P1Y mean one month and one year. Use the store’s full billed amount as the main price on a custom paywall. To load one named offering:
For products, offering is a literal offering ID. An unknown ID returns offeringNotFoundError with empty offerings and products arrays. Without a filter, the catalog includes all offerings.

Trials and introductory pricing

When present, intro contains:
type is trial or intro. This describes the offer’s price and duration. On iOS, the products catalog reports configured introductory pricing; its presence alone does not prove this user is eligible. The native store decides what applies at checkout. The single-offering command below performs an additional iOS eligibility check and suppresses an intro offer when the user is known to be ineligible.

Load one offering with display-ready package details

Here default, an empty value, or an omitted offering means the current RevenueCat offering. A named offering selects that offering. The array follows RevenueCat’s package order:
pricePerUnitString is a monthly equivalent for periods longer than one month, otherwise null. It is supporting information: the annual amount is still billed annually. introOffer is null when no offer is returned, and its type is free_trial, pay_as_you_go, or pay_up_front. On iOS, an unknown eligibility answer can still include the configured offer, so do not promise a trial before store confirmation. Errors set offeringsData to [] and offeringsError to { code, message }. Codes include not_configured, fetch_failed, offering_not_found, and serialization errors; Android uses uppercase forms. A successful read sets offeringsError to null.

Identify the customer

Use the same stable, case-sensitive account ID on your backend, in RevenueCat, and across iOS and Android. Encode it when sending a URL. A RevenueCat App User ID is an identifier, not a credential.
login, logout, and whoami answer on the same identity channel. They add new (RevenueCat’s created flag for login) and entitlements: { active, all } to the base envelope.
  • whoami reads the current identity without signing in or changing users.
  • login binds your account ID. RevenueCat applies its own anonymous-user merge and transfer rules; do not assume every existing account is automatically merged.
  • logout returns RevenueCat to an anonymous identity. An already-anonymous user is treated as success. Run it when your own user signs out on a shared device.
  • Switching accounts can use login with the next ID directly.
Purchases and paywalls can run without external_id on bridge 2, using the current RevenueCat user, including an anonymous user. Signing in later associates the purchase according to RevenueCat’s identity rules. For an account-bound checkout, wait for a successful explicit login response before opening the purchase flow.

Read entitlements and subscription lifecycle

Replace premium with an entitlement ID from your own RevenueCat project. No entitlement name is reserved by Despia. Each details[entitlementId] contains: Dates are ISO 8601 strings. A user can stop auto-renewal and still have active: true until expires. A billing issue is not itself a reason to revoke access while the entitlement is active. Consumables can complete successfully without granting an entitlement. Refresh customer state when the app opens and after purchases, restores, and account changes. RevenueCat may serve cached customer information; this is not a guarantee of a fresh network round trip or an exhaustive transaction ledger. See RevenueCat’s customer-info behavior. Verify server-controlled access on your backend using the same authenticated account ID.

Purchase a product

Use an id returned by products (or productId from offerings). On iOS it is the App Store product ID. Android subscriptions use subscriptionId:basePlanId; the value before the colon is the subscription ID, and the value after it is the base plan ID. One-time Android products use their plain ID. Do not invent or manually translate identifiers between stores. The runtime presents the native store purchase sheet. It can purchase subscriptions and one-time products, including products whose successful transaction grants no entitlement. Fulfill consumables on your backend after verification and deduplicate by transaction ID.

Purchase and paywall results

source identifies the flow: purchase, paywall, or redeem. Results use their own shape; they do not include every query-envelope field. entitlements is an array of active IDs, not the customer envelope’s { active, all } object. A normal dismissal has ok: false and cancelled: true. A successful transaction can have an empty entitlements array. For Android paywall purchases, product and transaction are null; use the returned entitlements and your backend’s RevenueCat events. Direct Android purchases can return the product and order ID. An iOS paywall can report restored: true, ok: false when a restore ran but granted no active entitlement. That does not mean a purchase succeeded. If the user then closes the paywall, a later dismissal result may arrive. Treat restored/cancelled states separately and make fulfillment idempotent.

Present a RevenueCat paywall

Design and publish the native paywall in RevenueCat, then present it from your web app. Omitting offering uses the current offering when default-paywall behavior is enabled. An unknown named offering can fall back to the current offering when that fallback is enabled in the native app; otherwise the flow reports an offering error. Use a known offering ID when selecting a specific paywall. The result arrives through onRevenueCatResult with source: 'paywall'. On iOS, a transient purchase failure can leave the paywall open for retry; closing it after that failure reports the failure rather than an ordinary cancellation. iOS paywalls and Customer Center require iOS 15 or later.

Redeem an Apple offer code

On iPhone and iPad, this opens Apple’s offer-code redemption sheet. The immediate result has source: 'redeem', ok: true, and code: 'presented'. It acknowledges presentation only: it does not prove that a code was accepted or that the user gained an entitlement. Refresh customer after redemption and use RevenueCat webhooks for backend access changes. The command does not take a code parameter; the user enters the code in Apple’s sheet. Configure offer codes in App Store Connect and RevenueCat first. See RevenueCat’s Apple offer-code guide. Android does not present this sheet. Google Play codes are redeemed through Google Play; do not send the iOS redemption command as an Android checkout flow.

Customer Center and restoring purchases

Customer Center lets users restore purchases and reach their store subscription-management options from native UI. Configure its management options in RevenueCat. Use a visible Restore Purchases or Manage Subscription button to open it. Refund events are iOS only. On Android, configure a custom support or subscription-management URL in Customer Center instead of waiting for an iOS refund event. Refund approval, renewals, billing failures, and expirations while the app is closed belong in your RevenueCat webhook handler.

Legacy purchase history and callbacks

Existing calls remain available:
restoredData contains store purchase rows. Depending on platform and available store data, rows include transactionId, originalTransactionId, productId, type, entitlementId, isActive, willRenew, purchaseDate, originalPurchaseDate, expirationDate, store, country, environment, receipt, externalUserId, isAnonymous, and provider. This query reads purchase state; it is not a substitute for an explicit store restore action. It is not guaranteed to include every expired purchase or consumed product. For new entitlement checks, prefer revenuecat://customer and entitlements.active. Use Customer Center for user-initiated restore. window.onRevenueCatPurchase(rawCustomerInfo) remains a compatibility hook for purchase/customer-info updates. iOS also supports window.iapSuccess(rawCustomerInfo). Do not treat either callback’s arrival as independent backend verification, or assume their raw payload matches the unified customer envelope. New purchase UI should handle onRevenueCatResult and refresh customer.

Errors and recovery

Handle ok: false before reading the successful response fields. Error codes differ in casing between platforms; compare case-insensitively when matching common conditions and retain the original code for diagnostics. RevenueCat can also return its own SDK error codes. Do not reduce every error to cancellation. Do not unlock access from ok alone: check the relevant entitlement or verify the transaction on your backend.

Web checkout and backend verification

Native schemes run inside Despia’s iOS and Android apps. In a normal browser, use your configured RevenueCat Web Purchase Link or web checkout instead. Associate it with the same account ID and verify access through your backend. Use RevenueCat webhooks for server-side purchases, renewals, cancellations, billing issues, and refunds. Authenticate incoming webhooks, process events idempotently, and keep RevenueCat secret API keys on the server. A client-supplied App User ID must never authorize access to another user’s protected data.