Q: How do I set up RevenueCat for In-App Purchases in WebViewGold?
Integrating RevenueCat is our recommended approach for handling in-app purchases and subscriptions. It simplifies the process across both iOS and Android, providing a powerful backend to manage transactions, entitlements, and analytics. Here is a step-by-step guide to get you started.
Step 1: Create Your RevenueCat Account
First, you need to create a free account on the RevenueCat website. Follow their setup wizards to add your app, configure your in-app products, and connect to App Store Connect and Google Play Console.
Step 2: Configure WebViewGold with Your API Keys
After setting up your project in RevenueCat, you need to add your unique API Key and Project ID to your WebViewGold project. You can find these keys in your RevenueCat dashboard.
For iOS (in Config.swift):
static let revenueCatAPIKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" // Your RevenueCat API Key
static let revenueCatProjectID = "xxxxxxxxx" // Your RevenueCat Project ID
For Android (in Config.java):
public static final String REVENUECAT_API_KEY = "xxxxxxxsxxxxxxxxxxxxxxxxxxxxxxxxxx"; // Your RevenueCat API Key
public static final String REVENUECAT_PROJECT_ID = "xxxxxxx"; // Your RevenueCat Project ID
Step 3: Trigger a Purchase from Your Web Content
To initiate a purchase or subscription, create a link in your HTML using the revenuecat:// URL scheme. This works for both iOS and Android.
<a href="revenuecat://purchase?external_id=user_123&product=sub_30_days">Subscribe Now</a>
Here’s what the parameters mean:
external_id: This should be your own unique identifier for the user (e.g., their email, username, or a database user ID). This is crucial for tracking purchases for specific users.product: This is the Product or Entitlement ID that you defined in your RevenueCat dashboard.
Step 4: Granting Access to Content
The most secure and reliable way to grant access to premium content is by using RevenueCat Webhooks. You can configure a URL on your server to receive real-time notifications from RevenueCat about events like initial purchases, renewals, and cancellations. Your server can then update the user’s access rights in your database automatically.
Please check out our documentation for detailed examples:
iOS: https://www.webviewgold.com/docs/iOS/#inapppurchases
Android: https://www.webviewgold.com/docs/android/#inapppurchases
For more detailed information, please also refer to the official WebViewGold website.
