跳到正文
DEV Community· kohei matsunobu·· 1 小時前AI 評分55

RevenueCat 入門:獨立開發者的應用程式內購指南

An Introduction to RevenueCat for Indie Developers

AI 導讀

RevenueCat 提供 SDK 和後端,協助獨立開發者管理 iOS、Android 及網頁內購與訂閲,並處理收據驗證及權限狀態。開發者仍須負責商店端協議、商品設定和付費功能解鎖,RevenueCat 並非支付處理商。Pro 計劃在 MTR 低於 $2,500 的月份免費;達到或超過該門檻時,按該期 MTR 總額收取 1%,以商店分成前的收入計算。

正文

Introduction

I'm Kohei Matsunobu, a second-year student at ZEN University studying intelligent informatics. I build iOS apps as a personal project.

Once you add subscriptions or one-time purchases to an app, the work grows quickly: receipt validation, renewal and cancellation state, different product IDs on iOS and Android, and the paywall itself. RevenueCat is a service that provides that billing infrastructure as an SDK and a backend.

This article is an introduction for indie developers. Pricing, the free tier, SDK names, commands, and APIs are limited to what I could verify in RevenueCat's official site and documentation. I have left out anything I could not verify. API keys in the code samples are placeholders only. This is not a usage report, and it does not include any app-specific experience or revenue figures.

What RevenueCat is

RevenueCat's documentation describes it as a backend and SDKs that wrap StoreKit, Google Play Billing, and RevenueCat Billing, so you can implement in-app and web purchases and subscriptions without maintaining your own IAP infrastructure. With the SDK, you can manage purchases across platforms.

In the official Implementation Responsibilities guide, RevenueCat is the single source of truth for subscription status across iOS, Android, and web. Receipt validation and the work of talking to native frameworks such as Apple's StoreKit and Google's BillingClient are handled automatically when you use the SDK.

RevenueCat is not a payment processor. The pricing FAQ answers "Does RevenueCat pay me?" by stating that you continue to be paid by Apple, Google, Stripe, or any other payment provider you integrate with RevenueCat. Creating products, presenting them to users, and unlocking paid features remain the developer's responsibility.

What gets easier for indie developers

For a solo developer, standing up and maintaining a billing server can crowd out work on the product itself. These are the parts of that burden that official docs describe RevenueCat as taking on.

You do not have to run your own receipt-validation server

After a purchase, the SDK sends the purchase token or receipt to RevenueCat's backend. The backend verifies it with the store and returns the customer's state (CustomerInfo). The Implementation Responsibilities guide assigns syncing, parsing, and verifying receipts, tracking entitlement status, and tracking purchase history to RevenueCat.

That means you do not have to implement Apple or Google server-side validation yourself, or maintain a server that recomputes subscription state on every renewal or expiration. If you serve premium content from your own server, though, you should not trust the client alone. Confirm access on the server with webhooks or the REST API, as described later.

You can treat iOS and Android purchases together

A single project can connect to more than one store, such as the Apple App Store and Google Play. A user's entitlements are shared across all apps in the same project. In app code, you can check an entitlement such as whether pro is active, instead of tracking every store-specific product identifier yourself.

Hybrid SDKs such as React Native and Flutter need a separate public API key for each platform (iOS and Android). The keys are in the dashboard under Project Settings > API keys > App specific keys.

Entitlements, Offerings, and Products

Three concepts show up throughout the official docs.

Concept Role
Product The individual SKU a user actually buys. In production, you set price and duration in App Store Connect, Google Play Console, or another store, then import the product into RevenueCat
Entitlement A level of access, features, or content the user is entitled to. You attach purchased products to it. App code checks this identifier rather than a list of product IDs
Offering The set of products shown on a paywall. A Package inside an offering groups equivalent products across iOS, Android, and web

The docs say most apps need only one entitlement, for example pro. If you have tiers such as Gold and Platinum, you create more than one. A subscription product unlocks an entitlement for the subscription duration. Non-consumable purchases, and consumable purchases that you attach to an entitlement, unlock that content permanently. The docs also note that you often should not attach consumables—such as extra lives in a game—to an entitlement.

Using Offerings is optional, but they are required for Paywalls, Experiments, and Targeting. You choose a Default Offering in the dashboard. If your paywall reads the current offering returned by getOfferings, you can change which products you present without shipping an app update. RevenueCat strongly recommends using current rather than hardcoding an identifier.

During development, you can create products in RevenueCat's Test Store and try the purchase flow without connecting a store. For production, create products in each store and import them with Import Products in the dashboard. The docs also state that if a user buys a product that has not been set up in RevenueCat, the transaction is still tracked and the product is created automatically.

Paywalls you can change from the dashboard

RevenueCat Paywalls let you remotely configure the paywall view without code changes or app updates. A paywall is attached to an Offering. The official docs describe building one from a template, from scratch, with the AI Editor, or by importing from Figma. A paywall can be a single screen or a multi-step flow, which is useful for onboarding.

In the app, you install the RevenueCat UI SDK, create a paywall for the Offering you want to serve, and present it. On iOS the UI package is RevenueCatUI. In React Native and Expo it is react-native-purchases-ui. RevenueCat Paywalls include a Restore Purchases button by default, so you do not have to write restore code unless you build your own paywall.

There are limits. According to the Paywalls documentation, supported platforms are iOS 15.0 and later, Android 7.0 (API 24) and later, Mac Catalyst 15.0 and later, macOS 12.0 and later, and web via Web Purchase Links. watchOS, tvOS, and visionOS are not supported. Each SDK has a recommended minimum version, and some features, such as multi-step paywalls, require a newer version. Those version numbers can change, so check the official table when you integrate.

The dashboard and metrics

The Overview page in the dashboard includes these cards:

  • Active Trials (currently tracked free trials)
  • Active Subscriptions (currently tracked paid subscriptions)
  • MRR (monthly recurring revenue)
  • Revenue (gross revenue in the last 28 days, before store fees and taxes)
  • New Customers (App User IDs created in the past 28 days)
  • Active Customers (App User IDs that communicated with RevenueCat in the past 28 days)

The docs say that for most customers, subscription metrics update in real time, while New Customers and Active Customers may be cached for 1–2 hours. You can toggle between sandbox and production data. Charts, however, show production transaction data only, because of limitations in sandbox environments.

Charts are built from purchase data stored in RevenueCat and do not rely on client-side event logging. The docs also note that figures may not match Apple, Google, or Stripe exactly. For tax reporting, use the payment processor's data, not RevenueCat's. Dates and times in the dashboard are in UTC unless explicitly specified.

Webhooks to your own server

If you want your backend to stay in sync with purchases and subscription state changes, use webhooks. You register an HTTPS endpoint under Integrations in the dashboard, and RevenueCat sends a JSON POST. Your server should return HTTP 200; any other status is treated as a failure. Failed deliveries are retried up to five times with exponential backoff, for a cumulative retry window of about 80 minutes. If the response takes longer than 60 seconds, RevenueCat disconnects, so the docs recommend returning 200 first and doing the work afterward.

Official examples of what you can do with webhooks include:

  • Keeping an up-to-date record of subscriptions and purchases in your own backend
  • Triggering automations from the subscription lifecycle
  • Reminding subscribers when they cancel, or notifying them about billing issues

RevenueCat recommends setting an authorization header, optionally enabling HMAC signatures (X-RevenueCat-Webhook-Signature), and handling duplicate events idempotently (delivery is at least once). For syncing state, the docs recommend calling the REST API GET /subscribers after any webhook, rather than writing custom logic for every event type.

Webhooks are a Pro feature. The current self-serve default plan is Pro, which is free up to the revenue threshold described below. If you are on a legacy plan without webhook access, the docs ask you to migrate to the new Pro plan.

Pricing

This section follows the Pricing page and the billing documentation. It reflects what those pages said when I checked them. Confirm the official pricing page before you rely on it, because it can change.

The current self-serve offering is a single standard plan, Pro, rather than a set of feature-gated tiers. The pricing page says the full suite of features comes standard, and that it is free to get started.

Billing is based on Monthly Tracked Revenue (MTR). MTR is the revenue RevenueCat tracks, in USD, during a one-month billing period, before the platform cut. It is the amount charged to the customer, not your net proceeds after store fees and taxes. It includes paid subscriptions, renewals, and one-time purchases. It is not the same as MRR. Billing periods do not follow the calendar month; they run from the same date in one month to the same date in the next (for example, July 15 to August 15).

On the Pro plan:

  • Months when MTR is under $2,500 are free
  • Months when MTR is over $2,500 are billed at 1% of total MTR for that period (not 1% of only the amount above the threshold)
  • Official examples: $2,500 MTR is billed as $25; $2,600 MTR is billed as $26
  • If MTR falls back below $2,500 in a later month, that month is free again

A credit card is optional at sign-up. If you reach $2,500 MTR without card details on file, parts of the product become unavailable until you add them. If you exceed the limit in your first month, you get a 30-day grace period from the moment you reach it. If you exceed it in a later month, access is restricted immediately until payment succeeds. Restricted abilities include viewing and filtering Charts, creating or exporting Customer Lists, viewing Customer History (Customer Details remain available), viewing individual events, creating new paywalls, and editing existing paywalls (using existing paywalls remains available).

Enterprise pricing is negotiated and depends on commitment, MTR, features, and support. This article does not quote Enterprise prices.

How to get started

This is an overview of the official flow and the caveats I could verify, not a click-by-click tutorial.

The usual sequence is:

  1. Create a RevenueCat account and project
  2. Prepare App Store Connect (and Google Play Console, if you ship on Android)
  3. Connect the store in RevenueCat, then configure Products, Entitlements, and Offerings
  4. Install the SDK and configure it with your public API key
  5. Optionally create a paywall in the dashboard and present it from the app
  6. Test, then switch from the Test Store API key to the platform-specific public API key before you submit for review

App Store Connect setup

Using RevenueCat does not remove the Apple-side work. The official App Store Connect setup guide includes these prerequisites:

  • Enroll in the Apple Developer Program
  • Accept the Paid Applications Agreement under Agreements, Tax, and Banking in App Store Connect
  • Add banking and tax information
  • Register a Bundle ID and enable the In-App Purchase capability
  • Create the app record in App Store Connect (it must match the Bundle ID in Xcode)
  • For subscriptions, create a Subscription Group and add products (Product ID, price, duration, and localizations)

For sandbox testing, create testers in App Store Connect under Users and Access > Sandbox Testers. When you first submit an app with subscriptions, you must include the in-app purchases in the same app version submission. The official guide stresses that they will not be reviewed otherwise. The first consumable, non-consumable, auto-renewable subscription, and non-renewing subscription must each be submitted with an app version.

To connect an Apple App Store app in RevenueCat, you add the app name, Bundle ID, Shared Secret, and In-App Purchase Key. Adding an App Store Connect API key is also recommended, so you can import products and prices from App Store Connect.

Official docs describe the credentials this way:

  • App-Specific Shared Secret: required for receipt validation with StoreKit 1. Apple has deprecated StoreKit 1, and new apps are recommended to use StoreKit 2
  • In-App Purchase Key: required for StoreKit 2 and RevenueCat Purchases v5.x and later (for example, iOS SDK 5.0.0+ and React Native SDK 8.0.0+). Without it, transactions may fail to be recorded, and users may not get access to what they bought. Generate it in App Store Connect under Users and Access → Integrations → In-App Purchase, upload the downloaded .p8 file to RevenueCat, and enter the Issuer ID. You can use the same key for all App Store apps under the same App Store Connect account
  • App Store Connect API Key: used to import products and prices. Create a key with at least App Manager access under Users and Access → Integrations → App Store Connect API, and upload it with Apple's original filename, AuthKey_XXXXXXXXXX.p8. You will also need the Issuer ID and the Vendor number from the top left of Payments and Financial Reports. This is not the same file as the In-App Purchase Key (SubscriptionKey_XXXXXXXXXX.p8)

In Xcode, add the In-App Purchase capability under Signing & Capabilities. If you are only testing with the Test Store, you can come back to this step when you connect the App Store.

After you connect a store, RevenueCat recommends setting up Platform Server Notifications, so purchase and subscription events reach RevenueCat sooner and webhook and integration delivery is faster.

Installing the SDK in Swift

For iOS and other Apple platforms, the official recommended install method is Swift Package Manager. CocoaPods and Carthage are also documented for projects that already use them.

In Xcode, choose File > Add Package Dependencies and paste this repository URL:

https://github.com/RevenueCat/purchases-ios-spm.git

Set the dependency rule to Up to Next Major Version, starting from 5.0.0. Add the RevenueCat product to your app target, and add RevenueCatUI as well if you want paywalls or other UI components. To verify the install, add import RevenueCat and confirm that the project builds.

Configure the SDK once, early in the app lifecycle, and only with a public API key. Never embed a secret API key (the ones that start with sk_) in an app or website.

import RevenueCat

// Call this once, early in launch, for example in application(_:didFinishLaunchingWithOptions:)
Purchases.logLevel = .debug
Purchases.configure(
    withAPIKey: "<revenuecat_project_apple_api_key>",
    appUserID: "<app_user_id>"
)

<revenuecat_project_apple_api_key> and <app_user_id> are placeholders. Public keys are listed under API keys in the dashboard. For how appUserID works, including anonymous users and attaching your own user identifiers, see the official Identifying Users guide.

Check subscription status with getCustomerInfo and inspect whether the relevant entitlements are active. Fetch offerings with getOfferings.

Installing the SDK in React Native and Expo

In React Native and Expo, the core package is react-native-purchases, and UI components such as Paywalls and Customer Center are in react-native-purchases-ui. These packages already include the RevenueCat iOS SDK, so do not also add purchases-ios or purchases-ios-spm to your Xcode project. Doing so can cause duplicate package errors or version conflicts.

For a React Native app that is not an Expo project, the official prerequisite is React Native 0.80 or later.

npm install --save react-native-purchases react-native-purchases-ui

With yarn, use yarn add react-native-purchases react-native-purchases-ui. The React Native CLI installs the iOS CocoaPods dependencies automatically the first time you run the app. To verify the install, add import Purchases from 'react-native-purchases' and confirm that npx react-native run-ios or npx react-native run-android succeeds. Enable the In-App Purchase capability in Xcode when you are ready to distribute on the App Store. You do not need that capability to build and test with the Test Store.

The official Expo guide assumes Expo SDK 54 or later. To use and test RevenueCat with Expo, you need an Expo development build.

npx expo install expo-dev-client
npx expo install react-native-purchases react-native-purchases-ui

After you install the packages, a full build is required; hot reloading is not enough. The docs say that skipping the build can produce errors such as Invariant Violation: new NativeEventEmitter() requires a non-null argument.

Because this is a hybrid SDK, configure it with a separate public API key per platform. The values below are placeholders.

import { Platform } from 'react-native';
import { useEffect } from 'react';
import Purchases, { LOG_LEVEL } from 'react-native-purchases';

export default function App() {
  useEffect(() => {
    Purchases.setLogLevel(LOG_LEVEL.VERBOSE);

    if (Platform.OS === 'ios') {
      Purchases.configure({ apiKey: "<revenuecat_project_apple_api_key>" });
    } else if (Platform.OS === 'android') {
      Purchases.configure({ apiKey: "<revenuecat_project_google_api_key>" });
    }
  }, []);

  return null;
}

Fetching customer info and checking an entitlement looks like this:

try {
  const customerInfo = await Purchases.getCustomerInfo();

  if (typeof customerInfo.entitlements.active["<my_entitlement_identifier>"] !== "undefined") {
    // The entitlement is active
  }
} catch (e) {
  // Failed to fetch customer info
}

Expo Go does not run real in-app purchases

The official Expo guide is explicit about Expo Go. Expo Go is a sandbox that cannot run custom native code, including the native modules required for in-app purchases. react-native-purchases does include a Preview API Mode for Expo Go. In that environment, native calls are replaced with JavaScript-level mock APIs, so the app can load and run subscription-related logic without crashing. Real purchases do not work in this mode.

That is useful for previewing subscription UI and integration flow. To test in-app purchases and use real RevenueCat functionality, you must use a development build. For the iOS Simulator, the official guide walks through an EAS build with an ios-simulator profile.

As a related note, React Native SDK version 12 will require Swift Package Manager for RevenueCat's iOS dependencies. The docs currently describe SPM support in React Native and Expo as experimental, and the CocoaPods instructions apply to SDK 11. Check the official migration notes before you upgrade.

When it may not fit, and other caveats

Whether RevenueCat is a good fit depends on how you want to own billing. These points come from official documentation.

  • The stores still process payments. RevenueCat is not a payment processor. You still have to complete the Paid Applications Agreement, banking and tax setup, product creation, and app review in App Store Connect (or Google Play). Installing RevenueCat does not replace that store-side work.
  • Unlocking paid features is still your job. RevenueCat reports entitlement status; unlocking content and downloading purchased content are the developer's responsibility. If premium content is served from your server, the docs say not to trust the client alone—confirm access with webhooks or the REST API. Authenticate the REST API with a secret API key, and keep that key on the server only.
  • Expo Go cannot make real purchases. Preview API Mode can run logic, but you need a development build to test purchases.
  • Paywalls are not available on every Apple platform. watchOS, tvOS, and visionOS are officially unsupported. If you need a paywall there, you will need another approach, such as a custom UI.
  • Metrics may not match store reports. Charts use production transactions only. Differences can come from metric definitions or estimated currency conversion. Use the payment processor's data for tax reporting.
  • The 1% fee is calculated on MTR before store commission. It is not 1% of your net proceeds. Months under $2,500 are free; months over that threshold are billed at 1% of total MTR.
  • Leaving later means taking validation and state management back in-house. The official shutdown steps say to remove the SDK and, if needed, set up your own purchase validation and subscription management before you delete the project. Deleting a project is immediate and irreversible. Users on older app versions will lose access to RevenueCat services. Active customer subscriptions are not canceled when you delete the account.
  • Do not submit with the wrong API key. If you developed against the Test Store, switch from the Test Store API key to the platform-specific public API key before app review.
  • A purchase will not unlock access if you forget to attach the product to an entitlement. When you add a new product, attach it to the right entitlement. For consumables, check the official guidance on whether an entitlement is appropriate.

You can also implement StoreKit or Google Play Billing yourself and run your own validation server. If you already have a stable custom stack, or you do not want a third-party dependency, you do not have to use RevenueCat. As an introduction, it is a service to consider when you would rather not build receipt validation, cross-platform status, a dashboard, and remotely configurable paywalls from scratch.

Summary

RevenueCat provides SDKs and a backend for validating in-app purchases and subscriptions, tracking entitlement status, and analyzing the results. For indie developers, the main points are:

  • You can start without running your own receipt-validation server or subscription-state machine
  • Entitlements let you treat iOS and Android products as one access model
  • Paywalls, Charts, and webhooks cover a lot of the operational work from the dashboard
  • At the time I checked the docs, Pro features are free below $2,500 MTR per month, and months above that are billed at 1% of MTR (before store commission)

Store agreements, product setup, and review still sit with you, and unlocking paid features is still your app's and your server's responsibility. Expo Go cannot complete real purchases; use a development build. Put only public API keys in the app, and keep secret keys on a server.

For integration details, and for pricing or SDK versions that may change after this article, treat the official documentation below as the source of truth.

References

來源:DEV Community · dev.to