subscriptionStatus

A published property that indicates the subscription status of the user.

If you're using a custom PurchaseController, you must update this property whenever the user's entitlements change. Entitlements in Superwall.shared.grantedEntitlements are merged into every value published here, but don't use grants if your controller already computes the full subscription state; set this property directly instead.

You can also observe logical status changes via the SuperwallDelegate method subscriptionStatusDidChange(from:to:). Changes only to transaction metadata, such as an expiry date or renewal state, are reported through customerInfoDidChange instead.

Purpose

Indicates the current subscription status of the user and can be observed for changes using Combine or SwiftUI.

Signature

@PublishedSubscriptionStatus
public var subscriptionStatus: SubscriptionStatus { get set }

Parameters

This property accepts a SubscriptionStatus enum value:

  • .unknown - Status is not yet determined
  • .active(Set<Entitlement>) - User has active entitlements (set of entitlement identifiers)
  • .inactive - User has no active entitlements

Returns / State

Returns the current SubscriptionStatus. When using a PurchaseController, you must set this property yourself. Otherwise, Superwall manages it automatically.

Usage

Set subscription status (when using PurchaseController):

Superwall.shared.subscriptionStatus = .active(["premium", "pro_features"])
Superwall.shared.subscriptionStatus = .inactive

Grant access from your backend:

Superwall.shared.grantedEntitlements = [Entitlement(id: "premium")]

// Setting subscriptionStatus to .inactive does not revoke this grant.
Superwall.shared.grantedEntitlements = []

When grantedEntitlements contains an active entitlement, the published status remains active even if you assign .inactive. Set grantedEntitlements to an empty set to revoke those grants. The grants persist across launches, reset(), and identify().

Get current subscription status:

let status = Superwall.shared.subscriptionStatus
switch status {
case .unknown:
  print("Subscription status unknown")
case .active(let entitlements):
  print("User has active entitlements: \(entitlements)")
case .inactive:
  print("User has no active subscription")
}

Observe changes with Combine:

import Combine

class ViewController: UIViewController {
  private var cancellables = Set<AnyCancellable>()
  
  override func viewDidLoad() {
    super.viewDidLoad()
    
    Superwall.shared.$subscriptionStatus
      .sink { [weak self] status in
        self?.updateUI(for: status)
      }
      .store(in: &cancellables)
  }
  
  func updateUI(for status: SubscriptionStatus) {
    switch status {
    case .active:
      showPremiumContent()
    case .inactive:
      showFreeContent()
    case .unknown:
      showLoadingState()
    }
  }
}

SwiftUI observation:

struct ContentView: View {
  @StateObject var superwall = Superwall.shared
  
  var body: some View {
    VStack {
      switch superwall.subscriptionStatus {
      case .active(let entitlements):
        Text("Premium user with: \(entitlements.joined(separator: ", "))")
      case .inactive:
        Text("Free user")
      case .unknown:
        Text("Loading...")
      }
    }
  }
}

How is this guide?

On this page