Skip to content

Add custom variables support for paywalls#812

Merged
facumenzella merged 22 commits into
mainfrom
feature/custom-variables-paywalls
Mar 12, 2026
Merged

Add custom variables support for paywalls#812
facumenzella merged 22 commits into
mainfrom
feature/custom-variables-paywalls

Conversation

@facumenzella

@facumenzella facumenzella commented Feb 6, 2026

Copy link
Copy Markdown
Member

Summary

Add customVariables support for paywalls, allowing developers to pass dynamic string values (e.g., player name, level) to paywall templates at runtime using {{ custom.variable_name }} syntax.

Screenshot 2026-03-12 at 16 18 23

Changes

  • Add CustomVariableValue type and extension methods for dictionary conversion
  • Add CustomVariables parameter to PaywallOptions with JSON serialization
  • Thread custom variables through iOS native bridge (RevenueCatUI.m)
  • Thread custom variables through Android native bridge (Java + C#)
  • Add CustomVariablesEditor to Subtester app for runtime testing
  • Add PaywallOptionsAPITests

🤖 Generated with Claude Code

@facumenzella facumenzella marked this pull request as ready for review February 13, 2026 16:18
@facumenzella facumenzella requested a review from a team as a code owner February 13, 2026 16:18
@facumenzella facumenzella force-pushed the feature/custom-variables-paywalls branch from 2986542 to 02dd394 Compare March 10, 2026 14:21
facumenzella and others added 10 commits March 10, 2026 17:09
Adds the ability to pass custom variables to paywalls for text substitution
using the {{ custom.variable_name }} syntax.

Changes:
- Add `customVariables` parameter to `PaywallOptions` constructors
- Pass custom variables through iOS native layer (RevenueCatUI.m)
- Pass custom variables through Android native layer (PaywallTrampolineActivity)
- Add CustomVariablesEditor to Subtester for testing
- Add PaywallOptionsAPITests for API surface verification
- Bump PHC to 17.33.0 which includes custom variables support

Usage:
```csharp
var options = new PaywallOptions(
    customVariables: new Dictionary<string, string>
    {
        { "player_name", "John" },
        { "level", "42" }
    }
);
await PaywallsPresenter.Present(options);
```

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Aligns the Unity SDK's custom variables API with React Native and Flutter
SDKs by using a CustomVariableValue type with factory method pattern
instead of raw Dictionary<string, string>.

This allows adding new variable types (e.g., numbers, booleans) in the
future without breaking changes.

Usage:
```csharp
var options = new PaywallOptions(
    customVariables: new Dictionary<string, CustomVariableValue>
    {
        { "player_name", CustomVariableValue.String("John") },
        { "level", CustomVariableValue.String("42") },
    }
);
```

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…eValue

- Use PaywallActivityLaunchOptions.Builder and PaywallActivityLaunchIfNeededOptions.Builder
- Convert Map<String, String> to Map<String, CustomVariableValue.String>
- Fix method signatures to match SDK API

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix incorrect Android API usage: use setOfferingIdentifier() instead of
  non-existent setOfferingId() and setPresentedOfferingContext() methods
- Update purchases-hybrid-common from 17.37.0 to 17.39.0

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The builder's setOfferingIdentifier method requires @OptIn(InternalRevenueCatAPI)
which cannot be properly used from Java code. Use the deprecated public launch()
overloads instead for launchPaywall, which handle the internal API opt-in
themselves.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Unity requires .meta files alongside every asset. These were missing for:
- RevenueCatUI/Scripts/CustomVariableValue.cs
- IntegrationTests/Assets/APITests/PaywallOptionsAPITests.cs
- Subtester/Assets/Scripts/CustomVariablesEditor.cs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix RevenueCat.SimpleJSON namespace reference in PaywallOptions.cs
- Add missing .meta file for PaywallsBehaviourAPITests.cs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The deprecated launcher.launch() overloads no longer exist in PHC 17.41.1.
Use PaywallActivityLaunchOptions.Builder pattern consistent with
launchPaywallIfNeeded.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This belongs in the other/integration-tests2 branch (PR #735), not here.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@facumenzella facumenzella force-pushed the feature/custom-variables-paywalls branch from 0d4949a to 071bcde Compare March 10, 2026 16:09
@facumenzella facumenzella requested a review from vegaro March 11, 2026 15:00
facumenzella and others added 2 commits March 11, 2026 16:00
… paywall logic

Replaced runtime custom variables UI editor with Inspector-based editing,
added configurable offering identifier, and consolidated paywall presentation
into shared BuildPaywallOptions/FetchOfferingIfNeeded helpers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ank lines

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread RevenueCatUI/Scripts/CustomVariableValue.cs
Comment thread IntegrationTests/Assets/APITests/PaywallsBehaviourAPITests.cs
Comment thread RevenueCatUI/Scripts/CustomVariableValue.cs Outdated
facumenzella and others added 4 commits March 11, 2026 18:34
Resolve conflicts by integrating custom variables with main's new architecture:
- PaywallOptions: add customVariables alongside presentationConfiguration and purchaseLogic
- iOS bridge: thread customVariablesJson through all presentation functions (including purchase logic variants)
- Android bridge: thread customVariablesJson through PaywallViewPresenter (replaces deleted PaywallTrampolineActivity)
- Subtester: migrate custom variables to new PaywallScreen with inline key/value fields
- Remove old CustomVariablesEditor and PurchasesListener (replaced by new screen-based Subtester)
- Update PaywallOptionsAPITests for new constructor parameters

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Move customVariables param after purchaseLogic in PaywallOptions constructors
  to preserve positional argument compatibility with existing callers
- Skip null values in ToStringDictionary to prevent NRE when users pass
  null CustomVariableValue entries in the dictionary
- Add custom variables Inspector support to PaywallsBehaviour with
  serializable CustomVariableEntry array
- Restore PaywallsBehaviourAPITests.cs that was accidentally deleted
- Add positional argument compatibility tests to PaywallOptionsAPITests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… name

Also refactor PaywallOptions constructors to use constructor chaining and
eliminate redundant intermediate dictionary in CustomVariablesToJsonString.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add defaultOfferingIdentifier and defaultCustomVariables fields to TesterApp
- Pre-populate PaywallScreen fields from editor values
- Add offering ID text field to Paywalls screen UI
- Replace StoreKit config with PaywallsTester products
- Set API keys and default offering in scene

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@facumenzella facumenzella requested a review from vegaro March 12, 2026 13:00
Comment thread RevenueCatUI/Scripts/PaywallsBehaviour.cs Outdated
Comment thread RevenueCatUI/Scripts/PaywallsBehaviour.cs
Comment thread Subtester/Assets/Scenes/Main.unity Outdated
Comment thread Subtester/SKConfig.storekit
facumenzella and others added 3 commits March 12, 2026 16:00
…changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…n.unity

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ariables

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@facumenzella facumenzella requested a review from vegaro March 12, 2026 15:18
Comment thread RevenueCatUI/Editor/CustomVariableEntryDrawer.cs
Comment thread IntegrationTests/Assets/APITests/PaywallsBehaviourAPITests.cs Outdated
…iableEntry coverage

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@facumenzella facumenzella enabled auto-merge (squash) March 12, 2026 17:38
@facumenzella facumenzella merged commit 2ea64ee into main Mar 12, 2026
8 checks passed
@facumenzella facumenzella deleted the feature/custom-variables-paywalls branch March 12, 2026 18:30
rickvdl pushed a commit that referenced this pull request Mar 17, 2026
**This is an automatic release.**

## RevenueCat SDK
### ✨ New Features
* Add trackCustomPaywallImpression API (#863) via Toni Rico (@tonidero)
### 📦 Dependency Updates
* Updates purchases-hybrid-common to 17.51.1 (#866) via RevenueCat Git
Bot (@RCGitBot)
* [Android
9.26.1](https://github.com/RevenueCat/purchases-android/releases/tag/9.26.1)
* [Android
9.26.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.26.0)
* [Android
9.25.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.25.0)
* [Android
9.24.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.24.0)
* [iOS
5.65.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.65.0)
* [iOS
5.64.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.64.0)
* [iOS
5.63.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.63.0)
* [iOS
5.62.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.62.0)
* [AUTOMATIC BUMP] Updates purchases-hybrid-common to 17.51.0 (#864) via
RevenueCat Git Bot (@RCGitBot)
* [Android
9.26.1](https://github.com/RevenueCat/purchases-android/releases/tag/9.26.1)
* [Android
9.26.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.26.0)
* [Android
9.25.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.25.0)
* [Android
9.24.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.24.0)
* [iOS
5.65.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.65.0)
* [iOS
5.64.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.64.0)
* [iOS
5.63.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.63.0)
* [iOS
5.62.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.62.0)
* [AUTOMATIC BUMP] Updates purchases-hybrid-common to 17.50.0 (#862) via
RevenueCat Git Bot (@RCGitBot)
* [Android
9.26.1](https://github.com/RevenueCat/purchases-android/releases/tag/9.26.1)
* [Android
9.26.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.26.0)
* [Android
9.25.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.25.0)
* [Android
9.24.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.24.0)
* [iOS
5.65.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.65.0)
* [iOS
5.64.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.64.0)
* [iOS
5.63.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.63.0)
* [iOS
5.62.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.62.0)
* [AUTOMATIC BUMP] Updates purchases-hybrid-common to 17.49.0 (#860) via
RevenueCat Git Bot (@RCGitBot)
* [Android
9.26.1](https://github.com/RevenueCat/purchases-android/releases/tag/9.26.1)
* [Android
9.26.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.26.0)
* [Android
9.25.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.25.0)
* [Android
9.24.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.24.0)
* [iOS
5.65.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.65.0)
* [iOS
5.64.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.64.0)
* [iOS
5.63.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.63.0)
* [iOS
5.62.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.62.0)
* [AUTOMATIC BUMP] Updates purchases-hybrid-common to 17.48.0 (#859) via
RevenueCat Git Bot (@RCGitBot)
* [Android
9.26.1](https://github.com/RevenueCat/purchases-android/releases/tag/9.26.1)
* [Android
9.26.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.26.0)
* [Android
9.25.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.25.0)
* [Android
9.24.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.24.0)
* [iOS
5.65.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.65.0)
* [iOS
5.64.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.64.0)
* [iOS
5.63.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.63.0)
* [iOS
5.62.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.62.0)
* [AUTOMATIC BUMP] Updates purchases-hybrid-common to 17.47.0 (#858) via
RevenueCat Git Bot (@RCGitBot)
* [Android
9.26.1](https://github.com/RevenueCat/purchases-android/releases/tag/9.26.1)
* [Android
9.26.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.26.0)
* [Android
9.25.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.25.0)
* [Android
9.24.0](https://github.com/RevenueCat/purchases-android/releases/tag/9.24.0)
* [iOS
5.65.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.65.0)
* [iOS
5.64.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.64.0)
* [iOS
5.63.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.63.0)
* [iOS
5.62.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.62.0)

## RevenueCatUI SDK
### ✨ New Features
* Add custom variables support for paywalls (#812) via Facundo Menzella
(@facumenzella)

### 🔄 Other Changes
* Bump fastlane-plugin-revenuecat_internal from `e146447` to `3e8c384`
(#861) via dependabot[bot] (@dependabot[bot])
* Add .claude/ to .gitignore (#857) via Facundo Menzella (@facumenzella)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants