Superwall class is the main entry point for the Compat SDK. It provides methods for configuring the SDK, registering placements, managing user identity, and controlling paywall presentation.
Installation
Import
Configuration
configure()
Configures a shared instance of Superwall for use throughout your app. Call this as soon as your app starts to initialize the SDK.Your Superwall API Key from the dashboard settings. Get your key from the Superwall Dashboard.
Optional configuration object to customize SDK appearance and behavior. See SuperwallOptions for available options.
Optional purchase controller for handling subscription logic yourself. See PurchaseController for implementation details.
Optional callback invoked when Superwall finishes configuring.
Returns a promise that resolves to the configured Superwall instance.
Example
shared
Returns the configured shared instance of Superwall.The shared Superwall instance.
Example
Placement Registration
register()
Registers a placement to access a feature. When added to a campaign on the Superwall Dashboard, it can trigger a paywall based on audience filters and subscription status.The name of the placement to register. Must match a placement configured in your Superwall Dashboard.
Optional parameters to pass with the placement. Can be referenced in campaign audience filters. Keys beginning with
$ are reserved. Arrays and dictionaries are not supported.Optional handler that receives status updates about paywall presentation. See PaywallPresentationHandler.
Optional callback executed after registration. For non-gated paywalls, runs when dismissed or if user is paying. For gated paywalls, runs only if user is paying or begins paying.
Resolves when registration completes. If
feature callback is provided, resolves after feature is executed.Example with Feature Callback
Example with Promise Chaining
Example with Presentation Handler
getPresentationResult()
Preemptively gets the result of registering a placement without presenting a paywall.The placement name to check.
Optional parameters to pass with the placement.
Result indicating whether a paywall would be presented. See PresentationResult.
Example
User Management
identify()
Creates an account with Superwall by linking the provided userId to Superwall’s automatically generated alias.Your user’s unique identifier from your backend system.
Optional identity options. Set
restorePaywallAssignments to true to restore paywall assignments from the server.Example
reset()
Resets the userId, on-device paywall assignments, and data stored by Superwall.Example
setUserAttributes()
Sets user attributes for use in paywalls and on the Superwall dashboard.Object containing custom attributes. Values can be any JSON-encodable value, URLs, or Dates. Keys beginning with
$ are reserved. Arrays and dictionaries are not supported.Example
getUserAttributes()
Retrieves the user attributes set usingsetUserAttributes().
Object representing the user’s attributes.
Example
Subscription Status
setSubscriptionStatus()
Sets the subscription status of the user. Required when using a PurchaseController.The new subscription status. See SubscriptionStatus.
Example
getSubscriptionStatus()
Retrieves the current subscription status.The current subscription status.
Example
Experiment Assignments
getAssignments()
Gets all experiment assignments and returns them in an array.Array of experiment assignments.
This method tracks the
getAssignments event in the delegate.Example
confirmAllAssignments()
Confirms all experiment assignments and returns them in an array.Array of confirmed experiment assignments.
Assignments may differ when a placement is registered due to changes in user, placement, or device parameters.
Example
Paywall Control
dismiss()
Dismisses the presented paywall, if one exists.Example
preloadAllPaywalls()
Preloads all paywalls that the user may see based on campaigns and placements.First set
PaywallOptions.shouldPreload to false when configuring the SDK, then call this function when you want preloading to begin.Example
preloadPaywalls()
Preloads paywalls for specific placements.Set of placement names to preload.
Example
Delegate
setDelegate()
Sets the delegate that handles Superwall lifecycle events.An object implementing the SuperwallDelegate interface, or
undefined to remove the delegate. See SuperwallDelegate.Example
Configuration Status
getConfigurationStatus()
Retrieves the current configuration status of the SDK.The configuration status:
PENDING, CONFIGURED, or FAILED.Example
Entitlements
getEntitlements()
Retrieves the entitlements tied to the device.Object containing entitlements information.
Example
Deep Links
handleDeepLink()
Handles a deep link URL.The deep link URL to handle.
Returns
true if the deep link was handled by Superwall.Example
UI Customization
setInterfaceStyle()
Sets the user interface style, overriding the system setting.The desired interface style (
light, dark), or null to use system setting.Example
setLogLevel()
Sets the logging level for the SDK.The log level to set.
Example
Integration Attributes
setIntegrationAttributes()
Sets attributes for third-party integrations.Object mapping integration attribute keys to their IDs.
Example
getIntegrationAttributes()
Gets the currently set integration attributes.Object mapping integration attributes to their IDs.
Example
Complete Example
See Also
- SuperwallDelegate - Event handler methods
- PurchaseController - Custom purchase handling
- Getting Started Guide - Complete setup guide