Events

The Mini App can receive events from the mini-app SDK, onto which a handler can be attached using the OpenWeb3.WebApp.onEvent(eventType, eventHandler) method. Inside eventHandler the this object refers to OpenWeb3.WebApp, the set of parameters sent to the handler depends on the event type. Below is a list of possible events:

EventTypeDescription
themeChangedOccurs whenever theme settings are changed in the user's app (including switching to night mode).
eventHandler receives no parameters, new theme settings and color scheme can be received via this.themeParams and this.colorScheme respectively.
viewportChangedOccurs when the visible section of the Mini App is changed.

eventHandler receives an object with the single field isStateStable. If isStateStable is true, the resizing of the Mini App is finished. If it is false, the resizing is ongoing (the user is expanding or collapsing the Mini App or an animated object is playing). The current value of the visible section’s height is available in this.viewportHeight.
mainButtonClickedOccurs when the main button is pressed.
eventHandler receives no parameters.
backButtonClickedOccurrs when the back button is pressed.
eventHandler receives no parameters.
popupClosedOccurrs when the opened popup is closed.
eventHandler receives an object with the single field button_id – the value of the field id of the pressed button. If no buttons were pressed, the field button_id will be null.
qrTextReceivedOccurs when the QR code scanner catches a code with text data.
eventHandler receives an object with the single field data containing text data from the QR code.
scanQrPopupClosedOccurs when the QR code scanner popup is closed by the user.
eventHandler receives no parameters.
clipboardTextReceivedOccurrs when the readTextFromClipboard method is called.
eventHandler receives an object with the single field data containing text data from the clipboard. If the clipboard contains non-text data, the field data will be an empty string. If the Mini App has no access to the clipboard, the field data will be null.
writeAccessRequestedOccurs when the write permission was requested.
eventHandler receives an object with the single field status containing one of the statuses:

- allowed – user granted write permission to the bot,
- cancelled – user declined this request.
contactRequestedOccurrs when the user's phone number was requested.
eventHandler receives an object with the single field status containing one of the statuses:

- sent – user shared their phone number with the bot,
- cancelled – user declined this request.
biometricManagerUpdatedOccurs whenever BiometricManager object is changed.
eventHandler receives no parameters.
biometricAuthRequestedOccurs whenever biometric authentication was requested.
eventHandler receives an object with the field isAuthenticated containing a boolean indicating whether the user was authenticated successfully. If isAuthenticated is true, the field biometricToken will contain the biometric token stored in secure storage on the device.
biometricTokenUpdatedOccurs whenever the biometric token was updated.
eventHandler receives an object with the single field isUpdated, containing a boolean indicating whether the token was updated.