Superwall

class Superwall(context: Context, apiKey: String, purchaseController: PurchaseController?, options: SuperwallOptions?, activityProvider: ActivityProvider?, completion: (Result<Unit>) -> Unit?) : PaywallViewEventCallback(source)

Constructors

Link copied to clipboard
constructor(context: Context, apiKey: String, purchaseController: PurchaseController?, options: SuperwallOptions?, activityProvider: ActivityProvider?, completion: (Result<Unit>) -> Unit?)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

A property that indicates current configuration state of the SDK.

Link copied to clipboard
Link copied to clipboard
val customerInfo: StateFlow<CustomerInfo>

Exposes customer info as a stateflow.

Link copied to clipboard

The delegate that handles Superwall lifecycle events.

Link copied to clipboard
Link copied to clipboard

The externalAccountId for the current user. Provided to Google Play billing upon purchase as a SHA256 of the userId. If passIdentifiersToPlayStore option is provided, this will be the userId.

Link copied to clipboard

Gets the current integration identifiers as a map.

Link copied to clipboard

Indicates whether the user is logged in to Superwall.

Link copied to clipboard

Determines whether a paywall is being presented.

Link copied to clipboard

The PaywallInfo object of the most recently presented view.

Link copied to clipboard
Link copied to clipboard

Specifies the detail of the logs returned from the SDK to the console.

Link copied to clipboard

A convenience variable to access and change the paywall options that you passed to configure.

Link copied to clipboard

A map of product name to product identifier that allows you to override products on all paywalls.

Link copied to clipboard

The presented paywall view.

Link copied to clipboard

A flow emitting all Superwall placements as an alternative to delegate.

Link copied to clipboard
Link copied to clipboard

Properties stored about the user, set using setUserAttributes.

Link copied to clipboard

The current user's id.

Functions

Link copied to clipboard

Removes all of Superwall's pending local notifications.

Link copied to clipboard

Confirms all experiment assignments and returns them in an array.

Link copied to clipboard
suspend fun consume(purchaseToken: String): Result<String>
fun consume(purchaseToken: String, onConsumed: (Result<String>) -> Unit)

Initiates a consumption of an In-App product.

Link copied to clipboard
suspend fun deviceAttributes(): Map<String, Any?>

Properties stored about the device session, set internally by Superwall

Link copied to clipboard
suspend fun Superwall.dismiss()

Dismisses the presented paywall, if one exists.

Link copied to clipboard

Dismisses the presented paywall, if it exists, in order to present a different one.

Link copied to clipboard

Dismisses the presented paywall synchronously, if one exists. Warning: This blocks the calling thread.

Link copied to clipboard

Dismisses the presented paywall synchronously, if it exists, in order to present a different one. Warning: This blocks the calling thread.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open suspend override fun eventDidOccur(paywallEvent: PaywallWebEvent, paywallView: PaywallView)
Link copied to clipboard

Gets an array of all confirmed experiment assignments.

Link copied to clipboard

Gets the current CustomerInfo synchronously.

Link copied to clipboard
@JvmName(name = "getDelegate")
fun getJavaDelegate(): SuperwallDelegateJava?

Gets the Java delegate that handles Superwall lifecycle events.

Link copied to clipboard
suspend fun Superwall.getPaywall(placement: String, params: Map<String, Any>? = null, paywallOverrides: PaywallOverrides? = null, delegate: PaywallViewCallback): Result<PaywallView>
Link copied to clipboard
suspend fun Superwall.getPaywallOrThrow(placement: String, params: Map<String, Any>? = null, paywallOverrides: PaywallOverrides? = null, delegate: PaywallViewCallback): PaywallView
Link copied to clipboard
fun Superwall.getPaywallSync(request: PresentationRequest, onStateChanged: (PaywallState) -> Unit = {}): Either<PaywallView, Throwable>

Gets a paywall to present synchronously, providing updates on the lifecycle of the paywall through a callback. Warning: This blocks the calling thread until the paywall is returned.

Link copied to clipboard
suspend fun Superwall.getPresentationResult(placement: String, params: Map<String, Any>? = null): Result<PresentationResult>

Preemptively gets the result of registering an event.

Link copied to clipboard

Synchronously preemptively gets the result of registering an event.

Link copied to clipboard
suspend fun getProducts(vararg productIds: String): Result<Map<String, StoreProduct>>

Given a list of product identifiers, returns a map of identifiers to StoreProduct objects.

Link copied to clipboard

Handles a deep link sent to your app to open a preview of your paywall.

Link copied to clipboard
fun Superwall.identify(userId: String, options: IdentityOptions? = null)
Link copied to clipboard

Observe purchases made without using Paywalls.

Link copied to clipboard
fun observePurchaseError(product: ProductDetails, error: Throwable)

Convenience method to observe purchase errors.

Link copied to clipboard
fun observePurchaseResult(billingResult: BillingResult, purchases: List<Purchase>)

Convenience method to observe successful purchases.

Link copied to clipboard
fun observePurchaseStart(product: ProductDetails)

Convenience method to observe when a purchase flow begins.

Link copied to clipboard
Link copied to clipboard

Preloads all paywalls that the user may see based on campaigns and triggers turned on in your Superwall dashboard.

Link copied to clipboard
fun preloadPaywalls(placementNames: Set<String>)

Preloads paywalls for specific event names.

Link copied to clipboard
suspend fun purchase(product: ProductDetails): Result<PurchaseResult>

Initiates a purchase of ProductDetails.

suspend fun purchase(product: StoreProduct): Result<PurchaseResult>

Initiates a purchase of StoreProduct.

suspend fun purchase(productId: String): Result<PurchaseResult>

Initiates a purchase of a product with the given productId.

fun purchase(product: ProductDetails, onFinished: (Result<PurchaseResult>) -> Unit)
fun purchase(productId: String, onFinished: (Result<PurchaseResult>) -> Unit)

fun purchase(product: StoreProduct, onFinished: (Result<PurchaseResult>) -> Unit)

Initiates a purchase of a StoreProduct with a callback.

Link copied to clipboard

Forces a configuration refresh. Used only for hot reload or explicit testing/debugging cases. Do not use unless explicitly instructed by Superwall dev team.

Link copied to clipboard
fun Superwall.register(placement: String, params: Map<String, Any>? = null, handler: PaywallPresentationHandler? = null, feature: () -> Unit? = null)

Registers an event to access a feature. When the event is added to a campaign on the Superwall dashboard, it can show a paywall.

Link copied to clipboard
fun reset()

Resets the userId, on-device paywall assignments, and data stored by Superwall.

Link copied to clipboard

Restores purchases

fun restorePurchases(onFinished: (Result<RestorationResult>) -> Unit): Job

Restores purchases and returns the result in a callback.

Link copied to clipboard

Sets 3rd party integration identifiers for this user. The identifiers will be passed to Superwall backend.

Link copied to clipboard
fun setInterfaceStyle(interfaceStyle: InterfaceStyle?)

Sets the user interface style, which overrides the system setting. Set to null to revert back to using the system setting.

Link copied to clipboard
@JvmName(name = "setDelegate")
fun setJavaDelegate(newValue: SuperwallDelegateJava?)

Sets the Java delegate that handles Superwall lifecycle events.

Link copied to clipboard
fun setPlatformWrapper(wrapper: String, version: String)

Do not use this function, this is for internal use only.

Link copied to clipboard
fun setSubscriptionStatus(subscriptionStatus: SubscriptionStatus)

Sets the entitlement status and updates the corresponding entitlement collections.

fun setSubscriptionStatus(vararg entitlements: String)

Simplified version of Superwall.setSubscriptionStatus that allows you to set the entitlements by passing in an array of strings. An empty list is treated as SubscriptionStatus.Inactive. Example: setSubscriptionStatus("default", "pro") equals SubscriptionStatus.Active(setOf(Entitlement("default"), Entitlement("pro"))) setSubscriptionStatus() equals SubscriptionStatus.Inactive

Link copied to clipboard
Link copied to clipboard
fun showAlert(title: String? = null, message: String? = null, actionTitle: String? = null, closeActionTitle: String = "Done", action: () -> Unit? = null, onClose: () -> Unit? = null)

Shows an alert with provided properties over the paywall UI. Will only show if the current paywall exists/is presented.

Link copied to clipboard

Toggles the paywall loading spinner on and off.