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:
EventType | Description |
---|---|
themeChanged | Occurs 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. |
viewportChanged | Occurs 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. |
mainButtonClicked | Occurs when the main button is pressed. eventHandler receives no parameters. |
backButtonClicked | Occurrs when the back button is pressed. eventHandler receives no parameters. |
popupClosed | Occurrs 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. |
qrTextReceived | Occurs 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. |
scanQrPopupClosed | Occurs when the QR code scanner popup is closed by the user. eventHandler receives no parameters. |
clipboardTextReceived | Occurrs 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. |
writeAccessRequested | Occurs 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. |
contactRequested | Occurrs 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. |
biometricManagerUpdated | Occurs whenever BiometricManager object is changed. eventHandler receives no parameters. |
biometricAuthRequested | Occurs 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. |
biometricTokenUpdated | Occurs whenever the biometric token was updated. eventHandler receives an object with the single field isUpdated, containing a boolean indicating whether the token was updated. |