Tracking Subscription State
Read or set subscription status from a Unity game.
If you do not pass a custom purchase controller, Superwall uses the native iOS and Android SDKs to manage purchases and subscription-related state.
Read Subscription Status
using Superwall;
var status = Superwall.Shared.SubscriptionStatus;
if (status.Type == SubscriptionStatus.StatusType.Active)
{
var active = (SubscriptionStatus.ActiveStatus)status;
Debug.Log($"Active entitlements: {active.Entitlements.Count}");
}You can also fetch customer info asynchronously:
Superwall.Shared.GetCustomerInfo(info =>
{
Debug.Log($"Customer: {info.UserId}");
Debug.Log($"Entitlements: {info.Entitlements.Count}");
});Set Subscription Status Manually
Set subscription status manually when another purchase system is the source of truth for access. In
a complete custom purchase integration, configure Superwall with an
IPurchaseController so paywall purchase and restore
actions are routed to your purchase code, then update SubscriptionStatus whenever the player's
entitlements change.
If you are using Superwall-managed purchases, do not set SubscriptionStatus directly. The native
iOS and Android SDKs update it automatically after purchases, restores, and receipt checks.
using System.Collections.Generic;
using Superwall;
var entitlements = new List<Entitlement>
{
new Entitlement
{
Id = "pro",
IsActive = true,
Type = EntitlementType.ServiceLevel
}
};
Superwall.Shared.SubscriptionStatus = SubscriptionStatus.CreateActive(entitlements);Set the status to inactive when the player loses access:
Superwall.Shared.SubscriptionStatus = SubscriptionStatus.CreateInactive();Listen for Changes
Implement ISuperwallDelegate when you need callbacks for subscription or customer changes.
public void SubscriptionStatusDidChange(SubscriptionStatus from, SubscriptionStatus to)
{
Debug.Log($"Subscription status changed: {from.Type} -> {to.Type}");
}
public void CustomerInfoDidChange(CustomerInfo from, CustomerInfo to)
{
Debug.Log($"Customer info changed for {to.UserId}");
}See Using the Superwall Delegate for setup.
How is this guide?