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 onboarding view.
A promise that resolves when the onboarding is dismissed.
This method closes the onboarding and cleans up associated resources. After dismissing, the view controller instance cannot be reused.
AdaptyError if the view reference is invalid.
Presents the onboarding 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 onboarding is presented.
Calling present on an already visible onboarding view will result in an error.
The onboarding will be displayed with the configured presentation style on iOS.
On Android, the onboarding 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 onboarding 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 createOnboardingView and provide standard closing behavior:
onClose - closes the onboarding when the close button is pressed or system back is usedIf you want to override the onClose listener, we strongly recommend returning true
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 { createOnboardingView } from '@adapty/capacitor';
const view = await createOnboardingView(onboarding);
const unsubscribe = await view.setEventHandlers({
onClose: () => {
console.log('Onboarding closed');
// Return true to keep default closing behavior
return true;
},
onActionPerformed: (action) => {
console.log('Action performed:', action.name);
},
onProductSelected: (product) => {
console.log('Product selected:', product.vendorProductId);
}
});
await view.present();
// Later, unsubscribe all handlers
unsubscribe();
Controller for managing onboarding views.
Remarks
This class provides methods to present, dismiss, and handle events for onboarding views created with the Onboarding Builder. Create instances using the createOnboardingView function rather than directly constructing this class.