Skip to content

Add number and boolean custom variable types#1683

Merged
facumenzella merged 8 commits into
mainfrom
feature/custom-variable-number-boolean
Mar 18, 2026
Merged

Add number and boolean custom variable types#1683
facumenzella merged 8 commits into
mainfrom
feature/custom-variable-number-boolean

Conversation

@facumenzella

@facumenzella facumenzella commented Mar 13, 2026

Copy link
Copy Markdown
Member

Summary

  • Extends CustomVariableValue sealed class with .number(double) and .boolean(bool) constructors
  • Updates Dart conversion to preserve native types through the method channel instead of converting everything to strings
  • Updates Android platform code (PaywallView.kt, PurchasesUiFlutterPlugin.kt) to map typed values to CustomVariableValue.Number and .Boolean
  • Updates iOS platform code (PurchasesUiPaywallView.swift, PurchasesUiFlutterPlugin.swift) to call setCustomVariableNumber and setCustomVariableBool
  • Updates tests and API tester for new types

Dependencies

Test plan

  • dart format . is clean
  • flutter analyze lib passes
  • flutter test passes (25/25)
  • API tester compiles
  • Verify string custom variables still work on device
  • Test number custom variables render correctly in paywalls
  • Test boolean custom variables render correctly in paywalls

🤖 Generated with Claude Code

Extends CustomVariableValue sealed class with .number(double) and
.boolean(bool) constructors. Updates platform code (iOS/Android) to
preserve types through the method channel instead of converting
everything to strings.

Depends on: RevenueCat/purchases-hybrid-common#1557

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@facumenzella facumenzella requested a review from a team as a code owner March 13, 2026 14:37
Updates PHC dependency across all platforms to pick up number and
boolean custom variable type support in the bridge layer. Also aligns
iOS PaywallView type checking order with PHC (Bool before NSNumber).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
setCustomVariableNumber and setCustomVariableBool are internal to
RevenueCatUI, so calling them directly from the Flutter plugin would
fail to compile. Instead, set customVariables on PaywallViewCreationParams
and let PHC's createPaywallView handle the type dispatch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
facumenzella and others added 2 commits March 16, 2026 15:23
Ensures the API tester will fail to compile if a new subtype is added
to the sealed CustomVariableValue hierarchy without updating the test.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
sealed would be a source-breaking change for downstream code that
exhaustively switches on CustomVariableValue. abstract final prevents
external subclassing without requiring exhaustive pattern matching,
making it safe to add new subtypes in future releases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@vegaro vegaro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments that are not very critical but would like you to take a look before merging

Comment thread purchases_ui_flutter/lib/custom_variable_value.dart Outdated
- Remove unnecessary Int/Long/Float cases in PaywallView.kt (Dart always sends doubles)
- Restore null filtering for customVariables on iOS before passing to PHC params
- Remove nativeValue from public API; move type-preserving conversion to internal function

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@facumenzella

Copy link
Copy Markdown
Member Author

Addressed all three review comments in 5601764:

  1. PaywallView.kt: Removed unnecessary Int, Long, Float cases — Dart always sends doubles through the method channel.
  2. PurchasesUiPaywallView.swift: Restored null filtering with compactMapValues { $0 } before passing to PHC params.
  3. custom_variable_value.dart: Removed nativeValue from the public API entirely. The type-preserving conversion now lives in the internal convertCustomVariablesToNative function using type checks on the concrete subclasses.

@facumenzella facumenzella enabled auto-merge (squash) March 18, 2026 16:48
@facumenzella facumenzella merged commit 045696b into main Mar 18, 2026
13 checks passed
@facumenzella facumenzella deleted the feature/custom-variable-number-boolean branch March 18, 2026 16:57
facumenzella added a commit to RevenueCat/react-native-purchases that referenced this pull request Mar 18, 2026
## Summary
- Extends `CustomVariableValue` with `number` and `boolean` types
(previously string-only)
- Passes typed values over the RN bridge instead of converting to
strings, letting native SDKs use them for conditional paywall logic
- Updates Android bridge (`BasePaywallViewManager`, `RNPaywallsModule`)
to read typed values via `ReadableType` dispatch
- Updates iOS bridge (`PaywallViewWrapper`) to call
`setCustomVariableNumber:forKey:` and `setCustomVariableBool:forKey:`
- iOS `RNPaywalls.m` (presentPaywall path) needs no changes — PHC's
`PaywallProxy` already handles typed values from the dictionary

Mirrors the Flutter implementation:
RevenueCat/purchases-flutter#1683

## Test plan
- [x] Unit tests pass (18 tests covering all types, mixed types, edge
cases)
- [x] API tester type-checks pass (`npm run apitest`)
- [ ] Manual test on iOS with number/boolean custom variables in a V2
paywall
- [ ] Manual test on Android with number/boolean custom variables in a
V2 paywall

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
facumenzella pushed a commit that referenced this pull request Mar 18, 2026
**This is an automatic release.**

## RevenueCat SDK
### ✨ New Features
* Add trackCustomPaywallImpression API (#1679) via Rick (@rickvdl)
* Adds Galaxy to the Store Enum (#1677) via Will Taylor (@fire-at-will)
### 📦 Dependency Updates
* [AUTOMATIC BUMP] Updates purchases-hybrid-common to 17.52.0 (#1689)
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)
* Updates purchases-hybrid-common to 17.51.1 (#1687) 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 (#1685)
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 (#1682)
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 (#1680)
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 (#1678)
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 (#1676)
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 number and boolean custom variable types (#1683) via Facundo
Menzella (@facumenzella)

### 🔄 Other Changes
* Bump fastlane-plugin-revenuecat_internal from `3e8c384` to `9a6911b`
(#1688) via dependabot[bot] (@dependabot[bot])
* Bump fastlane-plugin-revenuecat_internal from `e146447` to `3e8c384`
(#1681) via dependabot[bot] (@dependabot[bot])
facumenzella added a commit to RevenueCat/purchases-unity that referenced this pull request Mar 18, 2026
## Summary
- Extends `CustomVariableValue` with `Number(double)` and
`Boolean(bool)` factory methods
- Preserves native types (number, boolean) through JSON serialization
instead of converting everything to strings
- Updates Android `PaywallViewPresenter` to parse typed JSON values into
`CustomVariableValue.Number` and `.Boolean`
- Uncomments Number/Boolean support in `PaywallsBehaviour` enum and
Editor drawer
- Updates API tests for new types

Unity equivalent of
RevenueCat/purchases-flutter#1683

## Test plan
- [ ] Verify string custom variables still work on device
- [ ] Test number custom variables render correctly in paywalls
- [ ] Test boolean custom variables render correctly in paywalls
- [ ] API tests compile

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants