Superwall

Subscription Status

Methods for getting and setting the user's subscription status.

Deprecated SDK

We strongly recommend migrating to the new Superwall Expo SDK, see our migration guide for details.

Purpose

Methods for managing the user's subscription status. When using a PurchaseController, you must call setSubscriptionStatus() to update the user's subscription status whenever entitlements change.

Methods

getSubscriptionStatus()

Retrieves the current subscription status of the user.

Signature:

async getSubscriptionStatus(): Promise<SubscriptionStatus>

Returns: A Promise that resolves to the current SubscriptionStatus.

Usage:

const status = await Superwall.shared.getSubscriptionStatus()
console.log("Subscription status:", status)

setSubscriptionStatus()

Sets the subscription status of the user. When using a PurchaseController, you must call this method to update the user's subscription status. Alternatively, you can implement the SuperwallDelegate.subscriptionStatusDidChange delegate callback to receive notifications whenever the subscription status changes.

Signature:

async setSubscriptionStatus(status: SubscriptionStatus): Promise<void>

Parameters:

NameTypeDescription
statusSubscriptionStatusThe new subscription status.

Returns: A Promise that resolves once the subscription status has been updated.

Usage:

import { SubscriptionStatus } from "@superwall/react-native-superwall"

// Set active subscription with entitlements
const activeStatus = SubscriptionStatus.Active(["pro"])
await Superwall.shared.setSubscriptionStatus(activeStatus)

// Set inactive subscription
const inactiveStatus = SubscriptionStatus.Inactive()
await Superwall.shared.setSubscriptionStatus(inactiveStatus)

SubscriptionStatus Type

The SubscriptionStatus type represents the user's subscription state:

  • SubscriptionStatus.Active(entitlements: string[] \| Entitlement[]) - User has an active subscription with the specified entitlements
  • SubscriptionStatus.Inactive() - User does not have an active subscription
  • SubscriptionStatus.Unknown() - Subscription status is unknown

When to Update

  • After a successful purchase
  • After a purchase restoration
  • When a subscription expires
  • When a subscription is cancelled
  • On app launch (to sync with your backend)

How is this guide?

Edit on GitHub