Superwall
The shared instance of Superwall that provides access to all SDK features.
You must call configure() before accessing Superwall.shared, otherwise your app will crash.
Purpose
Provides access to the configured Superwall instance after calling configure().
Signature
public static var shared: Superwall { get }Parameters
This is a computed property with no parameters.
Returns / State
Returns the shared Superwall instance that was configured via configure().
Usage
Configure first (typically in AppDelegate or SceneDelegate):
Superwall.configure(apiKey: "pk_your_api_key")Then access throughout your app:
Superwall.shared.register(placement: "feature_access") {
// Feature code here
}Set user identity and attributes:
Superwall.shared.identify(userId: "user123")
Superwall.shared.setUserAttributes([
"plan": "premium",
"signUpDate": Date()
])Reset the user:
Superwall.shared.reset()Avoid calling Superwall.shared.reset() repeatedly. Resetting rotates the anonymous user ID, clears local paywall assignments, and requires the SDK to re-download configuration state. Only trigger a reset when a user explicitly logs out or you intentionally need to forget their identity. See User Management for more guidance.
Set delegate:
Superwall.shared.delegate = selfOverride products:
Superwall.shared.overrideProductsByName = [
"primary": "produceID_to_replace_primary_product"
]Access customer info:
// Get current customer info
let customerInfo = Superwall.shared.customerInfo
// Get customer info asynchronously
let customerInfo = await Superwall.shared.getCustomerInfo()
// Observe customer info changes
Superwall.shared.$customerInfo
.sink { customerInfo in
print("Customer has \(customerInfo.subscriptions.count) subscriptions")
}
.store(in: &cancellables)Set integration attributes:
Superwall.shared.setIntegrationAttributes([
.amplitudeUserId: "user123",
.mixpanelDistinctId: "distinct456",
.firebaseInstallationId: "abc123"
])Get device attributes:
let deviceAttributes = await Superwall.shared.getDeviceAttributes()
// Use in audience filters or for debugging
print("Device attributes: \(deviceAttributes)")Confirm all experiment assignments:
// Get all experiment assignments
let assignments = await Superwall.shared.confirmAllAssignments()
print("Confirmed \(assignments.count) assignments")Manually refresh configuration (development-only):
// Useful when hot-reloading paywalls during development
await Superwall.shared.refreshConfiguration()How is this guide?
Edit on GitHub