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 flow view.
A promise that resolves when the flow is dismissed.
This method closes the flow and cleans up associated resources. After dismissing, the view controller instance cannot be reused.
AdaptyError if the view reference is invalid.
Presents the flow 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 flow is presented.
Calling present on an already visible flow view will result in an error.
The flow will be displayed with the configured presentation style on iOS.
On Android, the flow 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 flow 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 createFlowView (see DEFAULT_FLOW_EVENT_HANDLERS).
Only two defaults close the view; all others keep it open:
onCloseButtonPress - closes the view (returns true)onError - closes the view (returns true)false),
including onAndroidSystemBack, onRestoreCompleted, and onPurchaseCompletedReturning true from a handler closes the view; returning false keeps it open.
To retain default behavior in a custom listener, return the same value as the default
implementation (only onCloseButtonPress and onError close the view by default).
Calling this method multiple times will replace previously registered handlers for provided events.
Register custom event handlers
import { createFlowView } from '@adapty/capacitor';
const view = await createFlowView(flow);
const unsubscribe = await view.setEventHandlers({
onPurchaseStarted: (product) => {
console.log('Purchase started:', product.vendorProductId);
},
onPurchaseCompleted: (result) => {
console.log('Purchase completed:', result.type);
// Return true to close the view after purchase (default keeps it open)
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 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 flow views.
Remarks
This class provides methods to present, dismiss, and handle events for flow views created with the Flow Builder. Create instances using the createFlowView function rather than directly constructing this class.