Serialize every Entitlement field on both native bridges - #8
Merged
Merged
Conversation
`serializeEntitlement` on iOS and Android emitted four keys: `id`, a hardcoded `type`, `isActive` and `productIds`. The C# `Entitlement` model has thirteen fields and `BridgeCallbackHandler.DeserializeEntitlement` already reads all of them, so `LatestProductId`, `Store`, `StartsAt`, `RenewedAt`, `ExpiresAt`, `IsLifetime`, `WillRenew`, `State` and `OfferType` were permanently null. A consumer could not tell a trial from a paid subscription, nor read an expiry or renewal state, from the entitlement it was handed. Both bridges now emit the full model with one vocabulary: enum values as the case names the C# enums parse case-insensitively (`playStore`, `inGracePeriod`, `trial`), dates as epoch milliseconds, and optional fields omitted rather than sent as null. On Android the SDK's `GRACE_PERIOD` / `BILLING_RETRY` names are mapped to the C# `InGracePeriod` / `InBillingRetryPeriod`; `UNKNOWN` is dropped. The Android-only offer types `SUBSCRIPTION` and `REVOKED` are sent under their own names and parse to null on the C# side, which has no member for them. Field names were checked against SuperwallKit 4.16.3 (`Entitlement.swift`) and superwall-android 2.7.23 (`Entitlement.kt`). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
serializeEntitlementon iOS and Android emitted four keys:id, a hardcodedtype,isActiveandproductIds. The C#Entitlementmodel has thirteen fields andBridgeCallbackHandler.DeserializeEntitlementalready reads all of them, so
LatestProductId,Store,StartsAt,RenewedAt,ExpiresAt,IsLifetime,WillRenew,StateandOfferTypewere permanently null. A consumer could not tell a trial from a paidsubscription, nor read an expiry or renewal state, from the entitlement it was handed.
Fix
Both bridges emit the full model with one vocabulary:
playStore,inGracePeriod,trial)On Android the SDK's
GRACE_PERIOD/BILLING_RETRYnames map to the C#InGracePeriod/InBillingRetryPeriod;UNKNOWNis dropped. The Android-only offer typesSUBSCRIPTIONandREVOKEDaresent under their own names and parse to null on the C# side, which has no member for them.
Verification
iOS device, sandbox trial:
OfferType == Trial,ExpiresAtandLatestProductIdpopulated on theSubscriptionStatusentitlement. Android device:Store == PlayStore,State == Active.Field names checked against SuperwallKit 4.16.3 (
Entitlement.swift) and superwall-android 2.7.23(
Entitlement.kt).🤖 Generated with Claude Code
https://claude.ai/code/session_01LTHPGB4qyAwDVYmQHW87ex