Clears all registered event handlers.
This method removes all previously registered event handlers. After calling this method, no event handlers will be active until you call setEventHandlers again.
Use this after dismiss to remove all event handlers
Dismisses the paywall view.
A promise that resolves when the paywall is dismissed.
This method closes the paywall and cleans up associated resources. After dismissing, the view controller instance cannot be reused.
AdaptyError if the view reference is invalid.
Presents the paywall view as a modal screen.
Optional presentation options
OptionaliosPresentationStyle?: AdaptyIOSPresentationStyleiOS presentation style. Available options: 'full_screen' (default) or 'page_sheet'. Only affects iOS platform.
A promise that resolves when the paywall is presented.
Calling present on an already visible paywall view will result in an error.
The paywall will be displayed with the configured presentation style on iOS.
On Android, the paywall is always presented as a full-screen activity.
AdaptyError if the view reference is invalid or the view is already presented.
Registers event handlers for paywall UI events.
Set of event handling callbacks. Only provided handlers will be registered or updated.
A promise that resolves to an unsubscribe function that removes all registered listeners.
Each event type can have only one handler — new handlers replace existing ones. Default handlers are registered automatically in createPaywallView and provide standard closing behavior:
onCloseButtonPress - closes the paywallonAndroidSystemBack - closes the paywall (Android only)onRestoreCompleted - closes the paywall after successful restoreonPurchaseCompleted - closes the paywall after successful purchaseIf you want to override these listeners, we strongly recommend returning true
(or purchaseResult.type !== 'user_cancelled' in case of onPurchaseCompleted)
from your custom listener to retain default closing behavior.
Calling this method multiple times will replace previously registered handlers for provided events.
Register custom event handlers
import { createPaywallView } from '@adapty/capacitor';
const view = await createPaywallView(paywall);
const unsubscribe = await view.setEventHandlers({
onPurchaseStarted: (product) => {
console.log('Purchase started:', product.vendorProductId);
},
onPurchaseCompleted: (result) => {
console.log('Purchase completed:', result.type);
// Return true to keep default closing behavior
return result.type !== 'user_cancelled';
},
onPurchaseFailed: (error) => {
console.error('Purchase failed:', error);
}
});
await view.present();
// Later, unsubscribe all handlers
unsubscribe();
Displays a dialog to the user.
Configuration for the dialog.
Optionalcontent?: stringDescriptive text that provides additional details about the reason for the dialog.
The action title to display as part of the dialog. If you provide two actions,
be sure primaryAction cancels the operation and leaves things unchanged.
OptionalsecondaryActionTitle?: stringThe secondary action title to display as part of the dialog.
Optionaltitle?: stringThe title of the dialog.
A promise that resolves to the action type that the user selected: 'primary' or 'secondary'.
Use this method to show custom dialogs within the paywall flow. If you provide two actions in the config, the primary action should cancel the operation and leave things unchanged, while the secondary action should confirm the operation.
AdaptyError if the view reference is invalid.
Controller for managing paywall views.
Remarks
This class provides methods to present, dismiss, and handle events for paywall views created with the Paywall Builder. Create instances using the createPaywallView function rather than directly constructing this class.