This file provides guidance to AI coding agents when working with code in this repository.
RevenueCat's official Unity SDK for in-app purchases and subscriptions. Provides C# scripts and native plugins for iOS and Android integration within Unity projects.
Related repositories:
- iOS SDK: https://github.com/RevenueCat/purchases-ios
- Android SDK: https://github.com/RevenueCat/purchases-android
- Hybrid Common: https://github.com/RevenueCat/purchases-hybrid-common — Native bridge layer
When implementing features or debugging, check these repos for reference and patterns.
Do NOT introduce breaking changes to the public API. The SDK is used by many production Unity games and apps.
Safe changes:
- Adding new optional parameters to existing methods
- Adding new classes, methods, or properties
- Bug fixes that don't change method signatures
- Internal implementation changes
Requires explicit approval:
- Removing or renaming public classes/methods/properties
- Changing method signatures (parameter types, required params)
- Changing return types
- Modifying behavior in ways that break existing integrations
purchases-unity/
├── RevenueCat/ # Main SDK package (UPM)
│ ├── Scripts/ # C# core SDK files
│ │ ├── Purchases.cs # Main entry point (MonoBehaviour singleton)
│ │ ├── PurchasesConfiguration.cs # Builder pattern config
│ │ ├── PurchasesWrapper*.cs # Platform-specific wrappers
│ │ └── *.cs # Data models and utilities
│ ├── Plugins/
│ │ ├── iOS/ # Native iOS integration (Objective-C)
│ │ ├── Android/ # Native Android integration (Java)
│ │ └── Editor/ # Dependency configuration
│ └── Editor/ # Editor tools & post-install
├── RevenueCatUI/ # UI SDK package (UPM)
│ ├── Scripts/ # Paywall/Customer center UI
│ └── Plugins/Android/ # Android UI library
├── IntegrationTests/ # Full Unity test project
│ └── Assets/APITests/ # API test files
├── Subtester/ # Package creation testing project
├── scripts/
│ └── create-unity-package.sh # Main build script
└── fastlane/ # Release automation
# Create .unitypackage files
./scripts/create-unity-package.sh -u <unity_path> [-v]Refer to fastlane/README.md for fastlane actions
- MonoBehaviour Singleton: Attach to GameObject or use
Purchases.shared - Inspector Configuration: API keys and options configurable in Unity Editor
- Programmatic Setup:
PurchasesConfiguration.Builder(apiKey)for runtime config
PurchasesWrapperiOS.cs— iOS native bridgePurchasesWrapperAndroid.cs— Android native bridgePurchasesWrapperNoop.cs— No-op for unsupported platformsPurchasesWrapper.cs— Abstract interface
CustomerInfo.cs— Subscription status and entitlementsOfferings.cs/Package.cs— Product offeringsStoreProduct.cs/SubscriptionInfo.cs— Product detailsEntitlementInfo.cs— Entitlement data
PaywallPresenter.cs— Paywall display logicPaywallsBehaviour.cs— Paywall behavior controllerCustomerCenterPresenter.cs— Customer center UI
purchases-hybrid-common— Native iOS/Android bridge- External Dependency Manager (EDM4U) — Manages native dependencies
| Platform | Minimum Version |
|---|---|
| Unity | 2021.3+ |
| iOS | 13.0+ |
| Android | API 21+ |
| Play Billing Library | 8.0.0+ |
Don't raise minimum versions unless explicitly required and justified.
Tests are located in IntegrationTests/Assets/APITests/:
PurchasesAPITests.cs— Main SDK testsCustomerInfoAPITests.cs— Customer info testsEntitlementInfoAPITests.cs— Entitlement tests- And more...
Run tests via Unity Test Runner in Edit Mode.
- Create feature branch from main
- Modify C# scripts in
RevenueCat/Scripts/orRevenueCatUI/Scripts/ - Modify native layer classes
RevenueCat/Plugins/ - Write tests in
IntegrationTests/Assets/APITests/ - Test locally with Subtester project
- Create PR with detailed explanation
RevenueCat/Scripts/revenuecat.purchases-unity.asmdef— Main SDKRevenueCat/Editor/revenuecat.purchases-unity.Editor.asmdef— Editor toolsRevenueCatUI/Scripts/revenuecat.purchases-unity-ui.asmdef— UI components
When creating a pull request, always add one of these labels to categorize the change:
| Label | When to Use |
|---|---|
pr:feat |
New user-facing features or enhancements |
pr:fix |
Bug fixes |
pr:other |
Internal changes, refactors, CI, docs, or anything that shouldn't trigger a release |
- Search for similar existing implementation in this repo first
- Check purchases-ios, purchases-android, and purchases-hybrid-common for patterns
- If there's a pattern, follow it exactly
- If not, propose options with tradeoffs and pick the safest default
- Don't invent APIs or file paths — verify they exist before referencing them
- Don't remove code you don't understand — ask for context first
- Don't make large refactors unless explicitly requested
- Keep diffs minimal — only touch what's necessary, preserve existing formatting
- Don't break the public API — if tests fail, investigate why
- Test on both iOS and Android — validate on real devices when possible
- Never commit API keys or secrets — do not stage or commit credentials or sensitive data