Superwall

CustomerInfo

Contains the latest subscription and entitlement information about the customer.

Purpose

Represents the complete customer information including all subscription transactions, non-subscription transactions, entitlements, and user identification.

Signature

class CustomerInfo {
  final List<SubscriptionTransaction> subscriptions;
  final List<NonSubscriptionTransaction> nonSubscriptions;
  final List<Entitlement> entitlements;
  final String userId;
}

Properties

PropertyTypeDescription
subscriptionsList<SubscriptionTransaction>All subscription transactions the user has made.
nonSubscriptionsList<NonSubscriptionTransaction>All non-subscription transactions (consumables and non-consumables) the user has made.
entitlementsList<Entitlement>All entitlements available to the user.
userIdStringThe ID of the user.

Usage

Getting customer info:

final customerInfo = await Superwall.shared.getCustomerInfo();

// Access user ID
print('User ID: ${customerInfo.userId}');

// Check entitlements
final activeEntitlements = customerInfo.entitlements
    .where((e) => e.isActive)
    .toList();

// Access subscriptions
for (final subscription in customerInfo.subscriptions) {
  if (subscription.isActive) {
    print('Active subscription: ${subscription.productId}');
  }
}

Checking for specific entitlements:

final customerInfo = await Superwall.shared.getCustomerInfo();

final hasPremium = customerInfo.entitlements.any(
  (entitlement) => 
    entitlement.id == 'premium' && 
    entitlement.isActive,
);

if (hasPremium) {
  // User has premium access
  showPremiumContent();
}

Filtering active subscriptions:

final customerInfo = await Superwall.shared.getCustomerInfo();

final activeSubscriptions = customerInfo.subscriptions
    .where((sub) => sub.isActive && !sub.isRevoked)
    .toList();

print('User has ${activeSubscriptions.length} active subscriptions');

How is this guide?

Edit on GitHub