Superwall

entitlements

The entitlements tied to the device, accessible via Superwall.shared.entitlements.

The entitlements property provides access to all entitlements, both active and inactive, as well as methods to query entitlements by product IDs.

Purpose

Provides access to the user's entitlements and methods to query them. Entitlements represent subscription tiers or features that a user has access to.

Signature

public var entitlements: EntitlementsInfo { get }

Properties and Methods

Property/MethodTypeDescription
activeSet<Entitlement>The active entitlements.
inactiveSet<Entitlement>The inactive entitlements.
allSet<Entitlement>All entitlements, regardless of whether they're active or not.
webSet<Entitlement>Active entitlements redeemed via the web.
byProductId(_:)(String) -> Set<Entitlement>Returns entitlements for a given product ID.
byProductIds(_:)(Set<String>) -> Set<Entitlement>Returns entitlements for a given set of product IDs. Available in version 4.10.0+.

Returns / State

Returns an EntitlementsInfo object that provides access to entitlements and methods to query them.

Usage

Get all active entitlements:

let activeEntitlements = Superwall.shared.entitlements.active

for entitlement in activeEntitlements {
  print("Active entitlement: \(entitlement.id)")
}

Get entitlements by product ID:

let productId = "com.example.premium_monthly"
let entitlements = Superwall.shared.entitlements.byProductId(productId)

print("Product \(productId) unlocks \(entitlements.count) entitlements")

Get entitlements by multiple product IDs (4.10.0+):

let productIds: Set<String> = [
  "com.example.premium_monthly",
  "com.example.premium_annual"
]

let entitlements = Superwall.shared.entitlements.byProductIds(productIds)

print("Products unlock \(entitlements.count) entitlements")

Check if user has specific entitlement:

let hasPremium = Superwall.shared.entitlements.active.contains { 
  $0.id == "premium" 
}

if hasPremium {
  showPremiumFeatures()
}

Get web entitlements:

let webEntitlements = Superwall.shared.entitlements.web

if !webEntitlements.isEmpty {
  print("User has \(webEntitlements.count) web entitlements")
}

How is this guide?

Edit on GitHub