Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Subtester/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ sysinfo.txt
*.unitypackage

iOS/
.vscode/
.vscode/

# Local RevenueCat API keys (copy local-api-keys.example.json to Assets/Tester/Resources/local-api-keys.json)
Assets/Tester/Resources/
Assets/Tester/Resources.meta
8 changes: 0 additions & 8 deletions Subtester/Assets/Resources.meta

This file was deleted.

1 change: 0 additions & 1 deletion Subtester/Assets/Resources/BillingMode.json

This file was deleted.

7 changes: 0 additions & 7 deletions Subtester/Assets/Resources/BillingMode.json.meta

This file was deleted.

204 changes: 0 additions & 204 deletions Subtester/Assets/Scenes/BuyButton.prefab

This file was deleted.

7 changes: 0 additions & 7 deletions Subtester/Assets/Scenes/BuyButton.prefab.meta

This file was deleted.

8 changes: 0 additions & 8 deletions Subtester/Assets/Scripts.meta

This file was deleted.

8 changes: 0 additions & 8 deletions Subtester/Assets/StreamingAssets.meta

This file was deleted.

69 changes: 69 additions & 0 deletions Subtester/Assets/Tester/Scripts/LocalApiKeys.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using UnityEngine;

namespace RevenueCat.Tester
{
/// <summary>
/// Loads RevenueCat API keys from a JSON resource file and applies them to the Purchases component.
/// This allows local development without modifying inspector settings.
/// </summary>
public static class LocalApiKeys
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
private static void ApplyLocalKeys()
{
var keysAsset = Resources.Load<TextAsset>("local-api-keys");
if (keysAsset == null)
{
return;
}

var purchases = Object.FindFirstObjectByType<Purchases>();
if (purchases == null)
{
return;
}

try
{
var keysData = JsonUtility.FromJson<ApiKeysData>(keysAsset.text);

bool anyKeyApplied = false;

if (!string.IsNullOrEmpty(keysData.apple))
{
purchases.revenueCatAPIKeyApple = keysData.apple;
anyKeyApplied = true;
}

if (!string.IsNullOrEmpty(keysData.google))
{
purchases.revenueCatAPIKeyGoogle = keysData.google;
anyKeyApplied = true;
}

if (!string.IsNullOrEmpty(keysData.amazon))
{
purchases.revenueCatAPIKeyAmazon = keysData.amazon;
anyKeyApplied = true;
}

if (anyKeyApplied)
{
Debug.Log("[LocalApiKeys] Applied local RevenueCat API keys from Resources/local-api-keys.json");
}
}
catch (System.Exception ex)
{
Debug.LogError($"[LocalApiKeys] Failed to parse local-api-keys.json: {ex.Message}");
}
}

[System.Serializable]
private class ApiKeysData
{
public string apple;
public string google;
public string amazon;
}
}
}
2 changes: 2 additions & 0 deletions Subtester/Assets/Tester/Scripts/LocalApiKeys.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions Subtester/Assets/UI Toolkit.meta

This file was deleted.

51 changes: 40 additions & 11 deletions Subtester/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
### Subtester sample app
This is a sample Unity app that has RevenueCat setup.
In order to use it:
- Video instructions: https://www.loom.com/share/bf8d07331a5b43c083efdf6b0f3ec724

1. Open the project with Unity
1. Open the Main scene
1. Select the PurchasesManager, and make sure that it has a PurchasesListener and Purchases object attached. If they're not attached, remove other objects from the PurchasesManager and add a PurchasesListener and Purchases object.
1. Set the RevenueCat API key in the Purchases object
1. Set the appUserId if needed in the Purchases object
1. Set the Parent Panel, Button Prefab and Customer Info Label objects in the PurchasesListener.
# Subtester Sample App

A sample/tester app for the RevenueCat Unity SDK. This project imports the SDK packages via local UPM file references in `Packages/manifest.json`, so edits to `RevenueCat/` and `RevenueCatUI/` in the repo are picked up live during development.

## Requirements

- **Unity Editor**: 6000.2.6f2 (see `ProjectSettings/ProjectVersion.txt`)

## Setup

1. Open the project in the Unity Editor (6000.2.6f2).
2. Open the scene: `Assets/Scenes/Main.unity`
3. Configure RevenueCat API keys:
- **Option A (Local JSON)**: Copy `local-api-keys.example.json` to `Assets/Tester/Resources/local-api-keys.json` (this path is gitignored), fill in your keys, and save. The app will load them at runtime.
- **Option B (Inspector)**: Select the Purchases component in the scene and set the API keys directly in its inspector fields.

## How It Works

The app is a UI Toolkit–driven tester built around `TesterApp.cs`. It displays a tab bar with screens for each major SDK feature area:

- **Identity**: Manage app user ID and customer identity.
- **Offerings**: Browse available offerings and products.
- **Purchase**: Execute purchases (only works on device; no-op in editor).
- **Customer**: View current customer information and active subscriptions.
- **Paywalls**: Display and test RevenueCatUI paywalls with custom variables.
- **Attributes**: Manage subscriber attributes.
- **Tools**: Utility functions (reset user, refresh data, etc.).

All screens log their output to an on-screen console.

## Running on Device

The RevenueCat SDK is a no-op in the Unity editor (native wrapper only exists on device). To test real SDK behavior:

1. Build to an iOS or Android device, or iOS simulator.
2. For iOS simulator, `SKConfig.storekit` is configured for StoreKit testing.

## Development

Edit files in `RevenueCat/` and `RevenueCatUI/`, then reload the scene or scripts in the editor—the local UPM references will pick up your changes immediately.
Loading