Hooks
useSuperwallEvents
Purpose
The useSuperwallEvents
hook provides a low-level way to subscribe to any native Superwall event. This is useful for advanced use cases or for events not covered by the more specific hooks. Listeners are automatically cleaned up when the component using this hook unmounts.
Parameters
callbacks?: SuperwallEventCallbacks
: An object where keys are event names and values are the corresponding callback functions.SuperwallEventCallbacks
: (Refer tosrc/useSuperwallEvents.ts
andsrc/SuperwallExpoModule.types.ts
for a full list of subscribable events and their payload types. Common events include):onPaywallPresent?: (info: PaywallInfo) => void
onPaywallDismiss?: (info: PaywallInfo, result: PaywallResult) => void
onPaywallSkip?: (reason: PaywallSkippedReason) => void
onPaywallError?: (error: string) => void
onSubscriptionStatusChange?: (status: SubscriptionStatus) => void
onSuperwallEvent?: (eventInfo: SuperwallEventInfo) => void
: For generic Superwall events.SuperwallEventInfo
:{ event: SuperwallEvent, params: Record<string, any> }
onCustomPaywallAction?: (name: string) => void
: When a custom action is triggered from a paywall.willDismissPaywall?: (info: PaywallInfo) => void
willPresentPaywall?: (info: PaywallInfo) => void
didDismissPaywall?: (info: PaywallInfo) => void
didPresentPaywall?: (info: PaywallInfo) => void
onPaywallWillOpenURL?: (url: string) => void
onPaywallWillOpenDeepLink?: (url: string) => void
onLog?: (params: { level: LogLevel, scope: LogScope, message: string | null, info: Record<string, any> | null, error: string | null }) => void
handlerId?: string
: (Optional) If provided, some events likeonPaywallPresent
,onPaywallDismiss
,onPaywallSkip
will only be triggered if the event originated from aregisterPlacement
call associated with the samehandlerId
. This is used internally byusePlacement
.
Returned Values
This hook does not return any values (void
). Its purpose is to set up and tear down event listeners.
Example
How is this guide?