type webAppUser = {
id: int,
is_bot?: bool,
first_name: string,
last_name?: string,
username?: string,
language_code?: string,
is_premium?: bool,
added_to_attachment_menu?: bool,
allows_write_to_pm?: bool,
photo_url?: string,
}type webAppChat = {
id: int,
type_: string,
title: string,
username?: string,
photo_url?: string,
}This object contains data that is transferred to the Mini App when it is opened. It is empty if the Mini App was launched from a keyboard button or from inline mode.
type webAppInitDataUnsafe = {
query_id?: string,
user?: webAppUser,
receiver?: webAppUser,
chat?: webAppChat,
chat_type?: string,
chat_instance?: string,
start_param?: string,
can_send_after?: int,
auth_date: int,
hash: string,
signature: string,
}type colorScheme = @as("light") Light | @as("dark") DarkThemeParams Mini Apps can adjust the appearance of the interface to match the Telegram user's app in real time. This object contains the user's current theme settings:
type themeParams = {
bg_color?: string,
text_color?: string,
hint_color?: string,
link_color?: string,
button_color?: string,
button_text_color?: string,
secondary_bg_color?: string,
header_bg_color?: string,
bottom_bar_bg_color?: string,
accent_text_color?: string,
section_bg_color?: string,
section_header_text_color?: string,
section_separator_color?: string,
subtitle_text_color?: string,
destructive_text_color?: string,
}type safeAreaInset = {
top: int,
bottom: int,
left: int,
right: int,
}type contentSafeAreaInset = {
top: int,
bottom: int,
left: int,
right: int,
}type t = {
initData: string,
initDataUnsafe: webAppInitDataUnsafe,
version: string,
platform: string,
colorScheme: colorScheme,
themeParams: themeParams,
isActve: bool,
isExpanded: bool,
viewportHeight: float,
viewportStableHeight: float,
mutable headerColor: string,
mutable backgroundColor: string,
mutable bottomBarColor: string,
mutable isClosingConfirmationEnabled: bool,
mutable isVerticalSwipesEnabled: bool,
isFullscreen: bool,
mutable isOrientationLocked: bool,
safeAreaInset: safeAreaInset,
contentSafeAreaInset: contentSafeAreaInset,
backButton: TelegramWebApp.BackButton.t,
mainButton: TelegramWebApp.BottomButton.t,
secondaryButton: TelegramWebApp.BottomButton.t,
settings: TelegramWebApp.SettingsButton.t,
hapticFeedback: TelegramWebApp.HapticFeedback.t,
cloudStorage: TelegramWebApp.CloudStorage.t,
biometricManager: TelegramWebApp.BiometricManager.t,
accelerometer: TelegramWebApp.Accelerometer.t,
deviceOrientation: TelegramWebApp.DeviceOrientation.t,
gyroscope: TelegramWebApp.Gyroscope.t,
locationManager: TelegramWebApp.LocationManager.t,
deviceStorage: TelegramWebApp.DeviceStorage.t,
secureStorage: TelegramWebApp.SecureStorage.t,
}Returns true if the user's app supports a version of the Bot API that is equal to or higher than the version passed as the parameter.
let isVersionAtLeast: (TelegramWebApp.WebApp.t, string) => boolA method that sets the app header color in the #RRGGBB format. You can also use keywords bg_color and secondary_bg_color.
Up to Bot API 6.9 You can only pass Telegram.WebApp.themeParams.bg_color or Telegram.WebApp.themeParams.secondary_bg_color as a color or bg_color, secondary_bg_color keywords.
let setHeaderColor: (TelegramWebApp.WebApp.t, string) => unitA method that sets the app background color in the #RRGGBB format. You can also use keywords bg_color and secondary_bg_color.
let setBackgroundColor: (TelegramWebApp.WebApp.t, string) => unitA method that sets the app's bottom bar color in the #RRGGBB format. You can also use the keywords bg_color, secondary_bg_color, and bottom_bar_bg_color. This color is also applied to the navigation bar on Android.
let setBottomBarColor: (TelegramWebApp.WebApp.t, string) => unitA method that enables a confirmation dialog while the user is trying to close the Mini App.
let enableClosingConfirmation: TelegramWebApp.WebApp.t => unitA method that disables the confirmation dialog while the user is trying to close the Mini App.
let disableClosingConfirmation: TelegramWebApp.WebApp.t => unitA method that enables vertical swipes to close or minimize the Mini App. For user convenience, it is recommended to always enable swipes unless they conflict with the Mini App's own gestures.
let enableVerticalSwipes: TelegramWebApp.WebApp.t => unitA method that disables vertical swipes to close or minimize the Mini App. This method is useful if your Mini App uses swipe gestures that may conflict with the gestures for minimizing and closing the app.
let disableVerticalSwipes: TelegramWebApp.WebApp.t => unitA method that requests opening the Mini App in fullscreen mode. Although the header is transparent in fullscreen mode, it is recommended that the Mini App sets the header color using the setHeaderColor method. This color helps determine a contrasting color for the status bar and other UI controls.
let requestFullscreen: TelegramWebApp.WebApp.t => unitA method that requests exiting fullscreen mode.
let exitFullscreen: TelegramWebApp.WebApp.t => unitA method that locks the Mini App’s orientation to its current mode (either portrait or landscape). Once locked, the orientation remains fixed, regardless of device rotation. This is useful if a stable orientation is needed during specific interactions.
let lockOrientation: TelegramWebApp.WebApp.t => unitA method that unlocks the Mini App’s orientation, allowing it to follow the device's rotation freely. Use this to restore automatic orientation adjustments based on the device orientation.
let unlockOrientation: TelegramWebApp.WebApp.t => unitA method that prompts the user to add the Mini App to the home screen. After successfully adding the icon, the homeScreenAdded event will be triggered if supported by the device. Note that if the device cannot determine the installation status, the event may not be received even if the icon has been added.
let addToHomeScreen: TelegramWebApp.WebApp.t => unittype homeScreenStatus =
| @as("unsupported") Unsupported
| @as("unknown") Unknown
| @as("added") Added
| @as("missed") Missed
| UndocumentedStatus(string)A method that checks if adding to the home screen is supported and if the Mini App has already been added. If an optional callback parameter is provided, the callback function will be called with a single argument status, which is a string indicating the home screen status.
let checkHomeScreenStatus: (
TelegramWebApp.WebApp.t,
~callback: homeScreenStatus => unit=?,
) => unit@unboxed
type invoiceStatus =
| @as("paid") Paid
| @as("cancelled") Cancelled
| @as("failed") Failed
| @as("pending") Pending
| UndocumentedStatus(string)Occurs when the Mini App becomes active (e.g., opened from minimized state or selected among tabs).
let onActivated: (TelegramWebApp.WebApp.t, Events.activated) => unitlet offActivated: (TelegramWebApp.WebApp.t, Events.activated) => unitOccurs when the Mini App becomes inactive (e.g., minimized or moved to an inactive tab).
let onDeactivated: (TelegramWebApp.WebApp.t, Events.deactivated) => unitlet offDeactivated: (TelegramWebApp.WebApp.t, Events.deactivated) => unitOccurs whenever theme settings are changed in the user's Telegram 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.
let onThemeChanged: (TelegramWebApp.WebApp.t, Events.themeChanged) => unitlet offThemeChanged: (TelegramWebApp.WebApp.t, Events.themeChanged) => unitOccurs 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.
let onViewportChanged: (TelegramWebApp.WebApp.t, Events.viewportChanged) => unitlet offViewportChanged: (TelegramWebApp.WebApp.t, Events.viewportChanged) => unitOccurs when the device's safe area insets change (e.g., due to orientation change or screen adjustments).
eventHandler receives no parameters. The current inset values can be accessed via this.safeAreaInset.
let onSafeAreaChanged: (TelegramWebApp.WebApp.t, Events.safeAreaChanged) => unitlet offSafeAreaChanged: (TelegramWebApp.WebApp.t, Events.safeAreaChanged) => unitOccurs when the safe area for content changes (e.g., due to orientation change or screen adjustments).
eventHandler receives no parameters. The current inset values can be accessed via this.contentSafeAreaInset.
let onContentSafeAreaChanged: (
TelegramWebApp.WebApp.t,
Events.contentSafeAreaChanged,
) => unitlet offContentSafeAreaChanged: (
TelegramWebApp.WebApp.t,
Events.contentSafeAreaChanged,
) => unitOccurs when the main button is pressed.
let onMainButtonClicked: (TelegramWebApp.WebApp.t, Events.mainButtonClicked) => unitlet offMainButtonClicked: (TelegramWebApp.WebApp.t, Events.mainButtonClicked) => unitOccurs when the secondary button is pressed.
let onSecondaryButtonClicked: (
TelegramWebApp.WebApp.t,
Events.secondaryButtonClicked,
) => unitlet offSecondaryButtonClicked: (
TelegramWebApp.WebApp.t,
Events.secondaryButtonClicked,
) => unitOccurrs when the back button is pressed.
let onBackButtonClicked: (TelegramWebApp.WebApp.t, Events.backButtonClicked) => unitlet offBackButtonClicked: (TelegramWebApp.WebApp.t, Events.backButtonClicked) => unitOccurrs when the Settings item in context menu is pressed.
let onSettingsButtonClicked: (
TelegramWebApp.WebApp.t,
Events.settingsButtonClicked,
) => unitlet offSettingsButtonClicked: (
TelegramWebApp.WebApp.t,
Events.settingsButtonClicked,
) => unitOccurrs when the opened invoice is closed.
eventHandler receives an object with the two fields: url – invoice link provided and status – one of the invoice statuses.
let onInvoiceClosed: (TelegramWebApp.WebApp.t, Events.invoiceClosed) => unitlet offInvoiceClosed: (TelegramWebApp.WebApp.t, Events.invoiceClosed) => unitOccurrs 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.
let onPopupClosed: (TelegramWebApp.WebApp.t, Events.popupClosed) => unitlet offPopupClosed: (TelegramWebApp.WebApp.t, Events.popupClosed) => unitOccurs 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.
let onQrTextReceived: (TelegramWebApp.WebApp.t, Events.qrTextReceived) => unitlet offQrTextReceived: (TelegramWebApp.WebApp.t, Events.qrTextReceived) => unitOccurs when the QR code scanner popup is closed by the user.
let onScanQrPopupClosed: (TelegramWebApp.WebApp.t, Events.scanQrPopupClosed) => unitlet offScanQrPopupClosed: (TelegramWebApp.WebApp.t, Events.scanQrPopupClosed) => unitOccurrs 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.
let onClipboardTextReceived: (
TelegramWebApp.WebApp.t,
Events.clipboardTextReceived,
) => unitlet offClipboardTextReceived: (
TelegramWebApp.WebApp.t,
Events.clipboardTextReceived,
) => unitOccurs when the write permission was requested.
eventHandler receives an object with the single field status containing one of the statuses.
let onWriteAccessRequested: (
TelegramWebApp.WebApp.t,
Events.writeAccessRequested,
) => unitlet offWriteAccessRequested: (
TelegramWebApp.WebApp.t,
Events.writeAccessRequested,
) => unitOccurrs when the user's phone number was requested.
eventHandler receives an object with the single field status containing one of the statuses.
let onContactRequested: (TelegramWebApp.WebApp.t, Events.contactRequested) => unitlet offContactRequested: (TelegramWebApp.WebApp.t, Events.contactRequested) => unitOccurs whenever BiometricManager object is changed.
let onBiometricManagerUpdated: (
TelegramWebApp.WebApp.t,
Events.biometricManagerUpdated,
) => unitlet offBiometricManagerUpdated: (
TelegramWebApp.WebApp.t,
Events.biometricManagerUpdated,
) => unitOccurs 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.
let onBiometricAuthRequested: (
TelegramWebApp.WebApp.t,
Events.biometricAuthRequested,
) => unitlet offBiometricAuthRequested: (
TelegramWebApp.WebApp.t,
Events.biometricAuthRequested,
) => unitOccurs whenever the biometric token was updated.
eventHandler receives an object with the single field isUpdated, containing a boolean indicating whether the token was updated.
let onBiometricTokenUpdated: (
TelegramWebApp.WebApp.t,
Events.biometricTokenUpdated,
) => unitlet offBiometricTokenUpdated: (
TelegramWebApp.WebApp.t,
Events.biometricTokenUpdated,
) => unitOccurs whenever the Mini App enters or exits fullscreen mode.
eventHandler receives no parameters. The current fullscreen state can be checked via this.isFullscreen.
let onFullscreenChanged: (TelegramWebApp.WebApp.t, Events.fullscreenChanged) => unitlet offFullscreenChanged: (TelegramWebApp.WebApp.t, Events.fullscreenChanged) => unitOccurs if a request to enter fullscreen mode fails.
eventHandler receives an object with the single field error, describing the reason for the failure.
let onFullscreenFailed: (TelegramWebApp.WebApp.t, Events.fullscreenFailed) => unitlet offFullscreenFailed: (TelegramWebApp.WebApp.t, Events.fullscreenFailed) => unitOccurs when the Mini App is successfully added to the home screen.
let onHomeScreenAdded: (TelegramWebApp.WebApp.t, Events.homeScreenAdded) => unitlet offHomeScreenAdded: (TelegramWebApp.WebApp.t, Events.homeScreenAdded) => unitOccurs after checking the home screen status.
eventHandler receives an object with the field status, which is a string indicating the current home screen status.
let onHomeScreenChecked: (TelegramWebApp.WebApp.t, Events.homeScreenChecked) => unitlet offHomeScreenChecked: (TelegramWebApp.WebApp.t, Events.homeScreenChecked) => unitOccurs when accelerometer tracking has started successfully.
let onAccelerometerStarted: (
TelegramWebApp.WebApp.t,
Events.accelerometerStarted,
) => unitlet offAccelerometerStarted: (
TelegramWebApp.WebApp.t,
Events.accelerometerStarted,
) => unitOccurs when accelerometer tracking has stopped.
let onAccelerometerStopped: (
TelegramWebApp.WebApp.t,
Events.accelerometerStopped,
) => unitlet offAccelerometerStopped: (
TelegramWebApp.WebApp.t,
Events.accelerometerStopped,
) => unitOccurs with the specified frequency after calling the start method, sending the current accelerometer data.
eventHandler receives no parameters, the current acceleration values can be received via this.x, this.y and this.z respectively.
let onAccelerometerChanged: (
TelegramWebApp.WebApp.t,
Events.accelerometerChanged,
) => unitlet offAccelerometerChanged: (
TelegramWebApp.WebApp.t,
Events.accelerometerChanged,
) => unitOccurs if a request to start accelerometer tracking fails.
eventHandler receives an object with the single field error, describing the reason for the failure.
let onAccelerometerFailed: (
TelegramWebApp.WebApp.t,
Events.accelerometerFailed,
) => unitlet offAccelerometerFailed: (
TelegramWebApp.WebApp.t,
Events.accelerometerFailed,
) => unitOccurs when device orientation tracking has started successfully.
let onDeviceOrientationStarted: (
TelegramWebApp.WebApp.t,
Events.deviceOrientationStarted,
) => unitlet offDeviceOrientationStarted: (
TelegramWebApp.WebApp.t,
Events.deviceOrientationStarted,
) => unitOccurs when device orientation tracking has stopped.
let onDeviceOrientationStopped: (
TelegramWebApp.WebApp.t,
Events.deviceOrientationStopped,
) => unitlet offDeviceOrientationStopped: (
TelegramWebApp.WebApp.t,
Events.deviceOrientationStopped,
) => unitOccurs with the specified frequency after calling the start method, sending the current orientation data.
eventHandler receives no parameters, the current device orientation values can be received via this.alpha, this.beta and this.gamma respectively.
let onDeviceOrientationChanged: (
TelegramWebApp.WebApp.t,
Events.deviceOrientationChanged,
) => unitlet offDeviceOrientationChanged: (
TelegramWebApp.WebApp.t,
Events.deviceOrientationChanged,
) => unitOccurs if a request to start device orientation tracking fails.
eventHandler receives an object with the single field error, describing the reason for the failure.
let onDeviceOrientationFailed: (
TelegramWebApp.WebApp.t,
Events.deviceOrientationFailed,
) => unitlet offDeviceOrientationFailed: (
TelegramWebApp.WebApp.t,
Events.deviceOrientationFailed,
) => unitOccurs when gyroscope tracking has started successfully.
let onGyroscopeStarted: (TelegramWebApp.WebApp.t, Events.gyroscopeStarted) => unitlet offGyroscopeStarted: (TelegramWebApp.WebApp.t, Events.gyroscopeStarted) => unitOccurs when gyroscope tracking has stopped.
let onGyroscopeStopped: (TelegramWebApp.WebApp.t, Events.gyroscopeStopped) => unitlet offGyroscopeStopped: (TelegramWebApp.WebApp.t, Events.gyroscopeStopped) => unitOccurs with the specified frequency after calling the start method, sending the current gyroscope data.
eventHandler receives no parameters, the current rotation rates can be received via this.x, this.y and this.z respectively.
let onGyroscopeChanged: (TelegramWebApp.WebApp.t, Events.gyroscopeChanged) => unitlet offGyroscopeChanged: (TelegramWebApp.WebApp.t, Events.gyroscopeChanged) => unitOccurs if a request to start gyroscope tracking fails.
eventHandler receives an object with the single field error, describing the reason for the failure.
let onGyroscopeFailed: (TelegramWebApp.WebApp.t, Events.gyroscopeFailed) => unitlet offGyroscopeFailed: (TelegramWebApp.WebApp.t, Events.gyroscopeFailed) => unitOccurs whenever LocationManager object is changed.
let onLocationManagerUpdated: (
TelegramWebApp.WebApp.t,
Events.locationManagerUpdated,
) => unitlet offLocationManagerUpdated: (
TelegramWebApp.WebApp.t,
Events.locationManagerUpdated,
) => unitOccurs when location data is requested.
eventHandler receives an object with the single field locationData of type LocationData, containing the current location information.
let onLocationRequested: (TelegramWebApp.WebApp.t, Events.locationRequested) => unitlet offLocationRequested: (TelegramWebApp.WebApp.t, Events.locationRequested) => unitOccurs when the message is successfully shared by the user.
let onShareMessageSent: (TelegramWebApp.WebApp.t, Events.shareMessageSent) => unitlet offShareMessageSent: (TelegramWebApp.WebApp.t, Events.shareMessageSent) => unitOccurs if sharing the message fails.
eventHandler receives an object with the single field error, describing the reason for the failure.
let onShareMessageFailed: (TelegramWebApp.WebApp.t, Events.shareMessageFailed) => unitlet offShareMessageFailed: (TelegramWebApp.WebApp.t, Events.shareMessageFailed) => unitOccurs when the emoji status is successfully set.
let onEmojiStatusSet: (TelegramWebApp.WebApp.t, Events.emojiStatusSet) => unitlet offEmojiStatusSet: (TelegramWebApp.WebApp.t, Events.emojiStatusSet) => unitOccurs if setting the emoji status fails.
eventHandler receives an object with the single field error, describing the reason for the failure.
let onEmojiStatusFailed: (TelegramWebApp.WebApp.t, Events.emojiStatusFailed) => unitlet offEmojiStatusFailed: (TelegramWebApp.WebApp.t, Events.emojiStatusFailed) => unitOccurs when the write permission was requested.
eventHandler receives an object with the single field status containing one of the statuses
let onEmojiStatusAccessRequested: (
TelegramWebApp.WebApp.t,
Events.emojiStatusAccessRequested,
) => unitlet offEmojiStatusAccessRequested: (
TelegramWebApp.WebApp.t,
Events.emojiStatusAccessRequested,
) => unitOccurs when the user responds to the file download request.
eventHandler receives an object with the single field status containing one of the statuses.
let onFileDownloadRequested: (
TelegramWebApp.WebApp.t,
Events.fileDownloadRequested,
) => unitlet offFileDownloadRequested: (
TelegramWebApp.WebApp.t,
Events.fileDownloadRequested,
) => unitA method that sets the app event handler.
let onEvent: (TelegramWebApp.WebApp.t, string, unit => unit) => unitA method that deletes a previously set event handler.
let offEvent: (TelegramWebApp.WebApp.t, string, unit => unit) => unitA method that sets the app event handler.
let onEvent1: (TelegramWebApp.WebApp.t, string, 'a => unit) => unitA method that deletes a previously set event handler.
let offEvent1: (TelegramWebApp.WebApp.t, string, 'a => unit) => unitA method used to send data to the bot. When this method is called, a service message is sent to the bot containing the data data of the length up to 4096 bytes, and the Mini App is closed. See the field web_app_data in the class Message.
This method is only available for Mini Apps launched via a Keyboard button.
let sendData: (TelegramWebApp.WebApp.t, string) => unittype chooseChatType =
| @as("users") Users
| @as("bots") Bots
| @as("groups") Groups
| @as("channels") ChannelsA method that inserts the bot's username and the specified inline query in the current chat's input field. Query may be empty, in which case only the bot's username will be inserted. If an optional choose_chat_types parameter was passed, the client prompts the user to choose a specific chat, then opens that chat and inserts the bot's username and the specified inline query in the input field. You can specify which types of chats the user will be able to choose from.
let switchInlineQuery: (
TelegramWebApp.WebApp.t,
string,
~choose_chat_types: array<chooseChatType>=?,
) => unittype openLinkOptions = {try_instant_view: bool}A method that opens a link in an external browser. The Mini App will not be closed.
Bot API 6.4+ If the optional options parameter is passed with the field try_instant_view=true, the link will be opened in Instant View mode if possible.
Note that this method can be called only in response to user interaction with the Mini App interface (e.g. a click inside the Mini App or on the main button)
let openLink: (
TelegramWebApp.WebApp.t,
string,
~options: openLinkOptions=?,
) => unitA method that opens a telegram link inside the Telegram app. The Mini App will not be closed after this method is called.
Up to Bot API 7.0 The Mini App will be closed after this method is called.
let openTelegramLink: (TelegramWebApp.WebApp.t, string) => unitA method that opens an invoice using the link url. The Mini App will receive the event invoiceClosed when the invoice is closed. If an optional callback parameter was passed, the callback function will be called and the invoice status will be passed as the first argument.
let openInvoice: (
TelegramWebApp.WebApp.t,
string,
~callback: invoiceStatus => unit=?,
) => unittype storyWidgetLink = {url: string, name?: string}type shareToStoryParams = {
text?: string,
widget_link?: storyWidgetLink,
}A method that opens the native story editor with the media specified in the media_url parameter as an HTTPS URL. An optional params argument of the type StoryShareParams describes additional sharing settings.
let shareToStory: (
TelegramWebApp.WebApp.t,
string,
~params: shareToStoryParams=?,
) => unitA method that opens a dialog allowing the user to share a message provided by the bot. If an optional callback parameter is provided, the callback function will be called with a boolean as the first argument, indicating whether the message was successfully sent. The message id passed to this method must belong to a PreparedInlineMessage previously obtained via the Bot API method savePreparedInlineMessage.
let shareMessage: (
TelegramWebApp.WebApp.t,
string,
~callback: bool => unit=?,
) => unittype emojiStatusParams = {duration?: int}A method that opens a dialog allowing the user to set the specified custom emoji as their status. An optional params argument of type EmojiStatusParams specifies additional settings, such as duration. If an optional callback parameter is provided, the callback function will be called with a boolean as the first argument, indicating whether the status was set.
Note: this method opens a native dialog and cannot be used to set the emoji status without manual user interaction. For fully programmatic changes, you should instead use the Bot API method setUserEmojiStatus after obtaining authorization to do so via the Mini App method requestEmojiStatusAccess.
let setEmojiStatus: (
TelegramWebApp.WebApp.t,
string,
~params: emojiStatusParams=?,
~callback: bool => unit=?,
) => unitA method that shows a native popup requesting permission for the bot to manage user's emoji status. If an optional callback parameter was passed, the callback function will be called when the popup is closed and the first argument will be a boolean indicating whether the user granted this access.
let requestEmojiStatusAccess: (TelegramWebApp.WebApp.t, ~callback: bool => unit=?) => unittype downloadFileParams = {url: string, file_name: string}A method that displays a native popup prompting the user to download a file specified by the params argument of type DownloadFileParams. If an optional callback parameter is provided, the callback function will be called when the popup is closed, with the first argument as a boolean indicating whether the user accepted the download request.
let downloadFile: (
TelegramWebApp.WebApp.t,
~params: downloadFileParams=?,
~callback: bool => unit=?,
) => unitA method that hides the on-screen keyboard, if it is currently visible. Does nothing if the keyboard is not active.
let hideKeyboard: TelegramWebApp.WebApp.t => unittype popupButtonType =
| @as("default") Default
| @as("ok") Ok
| @as("close") Close
| @as("cancel") Cancel
| @as("destructive") Destructivetype popupButton = {
id?: string,
type_?: popupButtonType,
text?: string,
}type popupParams = {
title?: string,
message: string,
buttons: array<popupButton>,
}A method that shows a native popup described by the params argument of the type PopupParams. The Mini App will receive the event popupClosed when the popup is closed. If an optional callback parameter was passed, the callback function will be called and the field id of the pressed button will be passed as the first argument.
let showPopup: (
TelegramWebApp.WebApp.t,
~params: popupParams=?,
~callback: string => unit=?,
) => unitA method that shows message in a simple alert with a 'Close' button. If an optional callback parameter was passed, the callback function will be called when the popup is closed.
let showAlert: (
TelegramWebApp.WebApp.t,
string,
~callback: unit => unit=?,
) => unitA method that shows message in a simple confirmation window with 'OK' and 'Cancel' buttons. If an optional callback parameter was passed, the callback function will be called when the popup is closed and the first argument will be a boolean indicating whether the user pressed the 'OK' button.
let showConfirm: (
TelegramWebApp.WebApp.t,
string,
~callback: bool => unit=?,
) => unittype scanQrPopupParams = {text?: string}A method that shows a native popup for scanning a QR code described by the params argument of the type ScanQrPopupParams. The Mini App will receive the event qrTextReceived every time the scanner catches a code with text data. If an optional callback parameter was passed, the callback function will be called and the text from the QR code will be passed as the first argument. Returning true inside this callback function causes the popup to be closed. Starting from Bot API 7.7, the Mini App will receive the scanQrPopupClosed event if the user closes the native popup for scanning a QR code.
let showScanQrPopup: (
TelegramWebApp.WebApp.t,
~params: scanQrPopupParams,
~callback: string => bool=?,
) => unitA method that closes the native popup for scanning a QR code opened with the showScanQrPopup method. Run it if you received valid data in the event qrTextReceived.
let closeScanQrPopup: TelegramWebApp.WebApp.t => unitA method that requests text from the clipboard. The Mini App will receive the event clipboardTextReceived. If an optional callback parameter was passed, the callback function will be called and the text from the clipboard will be passed as the first argument.
Note: this method can be called only for Mini Apps launched from the attachment menu and only in response to a user interaction with the Mini App interface (e.g. a click inside the Mini App or on the main button).
let readTextFromClipboard: (
TelegramWebApp.WebApp.t,
~callback: string => unit=?,
) => unitA method that shows a native popup requesting permission for the bot to send messages to the user. If an optional callback parameter was passed, the callback function will be called when the popup is closed and the first argument will be a boolean indicating whether the user granted this access.
let requestWriteAccess: (TelegramWebApp.WebApp.t, ~callback: bool => unit=?) => unitA method that shows a native popup prompting the user for their phone number. If an optional callback parameter was passed, the callback function will be called when the popup is closed and the first argument will be a boolean indicating whether the user shared its phone number.
let requestContact: (TelegramWebApp.WebApp.t, ~callback: bool => unit=?) => unitA method that informs the Telegram app that the Mini App is ready to be displayed.
It is recommended to call this method as early as possible, as soon as all essential interface elements are loaded. Once this method is called, the loading placeholder is hidden and the Mini App is shown.
If the method is not called, the placeholder will be hidden only when the page is fully loaded.
let ready: TelegramWebApp.WebApp.t => unitA method that expands the Mini App to the maximum available height. To find out if the Mini App is expanded to the maximum height, refer to the value of the Telegram.WebApp.isExpanded parameter
let expand: TelegramWebApp.WebApp.t => unitA method that closes the Mini App.
let close: TelegramWebApp.WebApp.t => unittype activated = unit => unittype deactivated = unit => unittype themeChanged = unit => unittype viewportChangedEvent = {isStateStable: bool}type viewportChanged = viewportChangedEvent => unittype safeAreaChanged = unit => unittype contentSafeAreaChanged = unit => unittype mainButtonClicked = unit => unittype secondaryButtonClicked = unit => unittype backButtonClicked = unit => unittype settingsButtonClicked = unit => unittype invoiceClosedEvent = {
url: string,
status: invoiceStatus,
}type invoiceClosed = invoiceClosedEvent => unittype popupClosedEvent = {button_id: Null.t<string>}type popupClosed = popupClosedEvent => unittype qrTextReceivedEvent = {data: string}type qrTextReceived = qrTextReceivedEvent => unittype scanQrPopupClosed = unit => unittype clipboardTextReceivedEvent = {data: Null.t<string>}type clipboardTextReceived = clipboardTextReceivedEvent => unit@unboxed
type writeAccessRequestedStatus =
| @as("allowed") Allowed
| @as("cancelled") Cancelled
| UndocumentedStatus(string)type writeAccessRequestedEvent = {
status: writeAccessRequestedStatus,
}type writeAccessRequested = writeAccessRequestedEvent => unit@unboxed
type contactRequestedStatus =
| @as("sent") Sent
| @as("cancelled") Cancelled
| UndocumentedStatus(string)type contactRequestedEvent = {
status: contactRequestedStatus,
}type contactRequested = contactRequestedEvent => unittype biometricManagerUpdated = unit => unittype biometricAuthRequestedEvent = {
isAuthenticated: bool,
biometricToken?: string,
}type biometricAuthRequested = biometricAuthRequestedEvent => unittype biometricTokenUpdatedEvent = {isUpdated: bool}type biometricTokenUpdated = biometricTokenUpdatedEvent => unittype fullscreenChanged = unit => unit@unboxed
type fullscreenError =
| @as("UNSUPPORTED") Unsupported
| @as("ALREADY_FULLSCREEN") AlreadyFullscreen
| UndocumentedError(string)type fullscreenFailedEvent = {error: fullscreenError}type fullscreenFailed = fullscreenFailedEvent => unittype homeScreenAdded = unit => unittype homeScreenCheckedEvent = {status: homeScreenStatus}type homeScreenChecked = homeScreenCheckedEvent => unittype accelerometerStarted = unit => unittype accelerometerStopped = unit => unittype accelerometerChanged = unit => unit@unboxed
type accelerometerFailedError =
| @as("UNSUPPORTED") Unsupported
| UndocumentedError(string)type accelerometerFailedEvent = {
error: accelerometerFailedError,
}type accelerometerFailed = accelerometerFailedEvent => unittype deviceOrientationStarted = unit => unittype deviceOrientationStopped = unit => unittype deviceOrientationChanged = unit => unit@unboxed
type deviceOrientationFailedError =
| @as("UNSUPPORTED") Unsupported
| UndocumentedError(string)type deviceOrientationFailedEvent = {
error: deviceOrientationFailedError,
}type deviceOrientationFailed = deviceOrientationFailedEvent => unittype gyroscopeStarted = unit => unittype gyroscopeStopped = unit => unittype gyroscopeChanged = unit => unit@unboxed
type gyroscopeFailedError =
| @as("UNSUPPORTED") Unsupported
| UndocumentedError(string)type gyroscopeFailedEvent = {error: gyroscopeFailedError}type gyroscopeFailed = gyroscopeFailedEvent => unittype locationManagerUpdated = unit => unittype locationRequestedEvent = {
locationData: TelegramWebApp.LocationManager.locationData,
}type locationRequested = locationRequestedEvent => unittype shareMessageSent = unit => unit@unboxed
type shareMessageError =
| @as("UNSUPPORTED") Unsupported
| @as("MESSAGE_EXPIRED") MessageExpired
| @as("MESSAGE_SEND_FAILED") MessageSendFailed
| @as("USER_DECLINED") UserDeclined
| @as("UNKNOWN_ERROR") UnknownError
| UndocumentedError(string)type shareMessageFailedEvent = {error: shareMessageError}type shareMessageFailed = shareMessageFailedEvent => unit@unboxed
type emojiStatusError =
| @as("UNSUPPORTED") Unsupported
| @as("SUGGESTED_EMOJI_INVALID") SuggestedEmojiInvalid
| @as("DURATION_INVALID") DurationInvalid
| @as("USER_DECLINED") UserDeclined
| @as("SERVER_ERROR") ServerError
| @as("UNKNOWN_ERROR") UnknownError
| UndocumentedError(string)type emojiStatusFailedEvent = {error: emojiStatusError}type emojiStatusSet = unit => unittype emojiStatusFailed = emojiStatusFailedEvent => unit@unboxed
type emojiStatusAccessStatus =
| @as("allowed") Allowed
| @as("cancelled") Cancelled
| UndocumentedError(string)type emojiStatusAccessRequestedEvent = {
status: emojiStatusAccessStatus,
}type emojiStatusAccessRequested = emojiStatusAccessRequestedEvent => unit@unboxed
type fileDownloadStatus =
| @as("downloading") Downloading
| @as("cancelled") Cancelled
| UndocumentedError(string)type fileDownloadRequestedEvent = {
status: fileDownloadStatus,
}type fileDownloadRequested = fileDownloadRequestedEvent => unitA reference to global Telegram.WebApp object.
Assumes <script src="https://telegram.org/js/telegram-web-app.js?59"></script>
is connectede beforehand.
let telegramWebApp: TelegramWebApp.WebApp.ttype t = {isStarted: bool, x: float, y: float, z: float}type accelerometerStartParams = {refresh_rate?: int}Starts tracking accelerometer data using params of type AccelerometerStartParams. If an optional callback parameter is provided, the callback function will be called with a boolean indicating whether tracking was successfully started.
let start: (
TelegramWebApp.Accelerometer.t,
accelerometerStartParams,
~callback: bool => unit=?,
) => TelegramWebApp.Accelerometer.tStops tracking accelerometer data. If an optional callback parameter is provided, the callback function will be called with a boolean indicating whether tracking was successfully stopped.
let stop: (
TelegramWebApp.Accelerometer.t,
~callback: bool => unit=?,
) => TelegramWebApp.Accelerometer.ttype t = {mutable isVisible: bool}A method that sets the button press event handler. An alias for Telegram.WebApp.onEvent('backButtonClicked', callback)
let onClick: (
TelegramWebApp.BackButton.t,
~callback: unit => unit,
) => TelegramWebApp.BackButton.tA method that removes the button press event handler. An alias for Telegram.WebApp.offEvent('backButtonClicked', callback)
let offClick: (
TelegramWebApp.BackButton.t,
~callback: unit => unit,
) => TelegramWebApp.BackButton.tA method to make the button active and visible.
let show: TelegramWebApp.BackButton.t => TelegramWebApp.BackButton.tA method to hide the button.
let hide: TelegramWebApp.BackButton.t => TelegramWebApp.BackButton.ttype t = {
isInited: bool,
isBiometricAvailable: bool,
biometricType: string,
isAccessRequested: bool,
isAccessGranted: bool,
isBiometricTokenSaved: bool,
deviceId: string,
}A method that initializes the BiometricManager object. It should be called before the object's first use. If an optional callback parameter was passed, the callback function will be called when the object is initialized.
let init: (
TelegramWebApp.BiometricManager.t,
~callback: unit => unit=?,
) => TelegramWebApp.BiometricManager.ttype biometricRequestAccessParams = {reason?: string}A method that requests permission to use biometrics according to the params argument of type BiometricRequestAccessParams. If an optional callback parameter was passed, the callback function will be called and the first argument will be a boolean indicating whether the user granted access.
let requestAccess: (
TelegramWebApp.BiometricManager.t,
biometricRequestAccessParams,
~callback: bool => unit=?,
) => TelegramWebApp.BiometricManager.ttype biometricAuthenticateParams = {reason?: string}A method that authenticates the user using biometrics according to the params argument of type BiometricAuthenticateParams. If an optional callback parameter was passed, the callback function will be called and the first argument will be a boolean indicating whether the user authenticated successfully. If so, the second argument will be a biometric token.
let authenticate: (
TelegramWebApp.BiometricManager.t,
biometricAuthenticateParams,
~callback: (bool, string) => unit=?,
) => TelegramWebApp.BiometricManager.tA method that updates the biometric token in secure storage on the device. To remove the token, pass an empty string. If an optional callback parameter was passed, the callback function will be called and the first argument will be a boolean indicating whether the token was updated.
let updateBiometricToken: (
TelegramWebApp.BiometricManager.t,
string,
~callback: bool => unit=?,
) => TelegramWebApp.BiometricManager.tA method that opens the biometric access settings for bots. Useful when you need to request biometrics access to users who haven't granted it yet.
Note that this method can be called only in response to user interaction with the Mini App interface (e.g. a click inside the Mini App or on the main button)
let openSettings: TelegramWebApp.BiometricManager.t => TelegramWebApp.BiometricManager.ttype bottomButtonType =
| @as("main") Main
| @as("secondary") Secondarytype bottomButtonPosition =
| @as("left") Left
| @as("right") Right
| @as("top") Top
| @as("bottom") Bottomtype t = {
type_: bottomButtonType,
mutable text: string,
mutable color: string,
mutable textColor: string,
mutable isVisible: bool,
mutable isActive: bool,
mutable hasShineEffect: bool,
mutable position: option<bottomButtonPosition>,
isProgressVisible: bool,
}A method to set the button text.
let setText: (
TelegramWebApp.BottomButton.t,
string,
) => TelegramWebApp.BottomButton.tA method that sets the button's press event handler. An alias for Telegram.WebApp.onEvent('mainButtonClicked', callback)
let onClick: (
TelegramWebApp.BottomButton.t,
~callback: unit => unit,
) => TelegramWebApp.BottomButton.tA method that removes the button's press event handler. An alias for Telegram.WebApp.offEvent('mainButtonClicked', callback)
let offClick: (
TelegramWebApp.BottomButton.t,
~callback: unit => unit,
) => TelegramWebApp.BottomButton.tA method to make the button visible. Note that opening the Mini App from the attachment menu hides the main button until the user interacts with the Mini App interface.
let show: TelegramWebApp.BottomButton.t => TelegramWebApp.BottomButton.tA method to hide the button.
let hide: TelegramWebApp.BottomButton.t => TelegramWebApp.BottomButton.tA method to enable the button.
let enable: TelegramWebApp.BottomButton.t => TelegramWebApp.BottomButton.tA method to disable the button.
let disable: TelegramWebApp.BottomButton.t => TelegramWebApp.BottomButton.tA method to show a loading indicator on the button.
It is recommended to display loading progress if the action tied to the button may take a long time. By default, the button is disabled while the action is in progress. If the parameter leaveActive=true is passed, the button remains enabled.
let showProgress: (
TelegramWebApp.BottomButton.t,
bool,
) => TelegramWebApp.BottomButton.tA method to hide the loading indicator.
let hideProgress: TelegramWebApp.BottomButton.t => TelegramWebApp.BottomButton.ttype params = {
text?: string,
color?: string,
text_color?: string,
has_shine_effect?: bool,
position?: TelegramWebApp.BottomButton.bottomButtonPosition,
is_active?: bool,
is_visible?: bool,
}A method to set the button parameters. The params parameter is an object containing one or several fields that need to be changed.
let setParams: (
TelegramWebApp.BottomButton.t,
params,
) => TelegramWebApp.BottomButton.ttype t@unboxed
type cloudStorageError =
| @as("UNKNOWN_ERROR") UnknownError
| UndocumentedError(string)A method that stores a value in the cloud storage using the specified key. The key should contain 1-128 characters, only A-Z, a-z, 0-9, _ and - are allowed. The value should contain 0-4096 characters. You can store up to 1024 keys in the cloud storage. If an optional callback parameter was passed, the callback function will be called. In case of an error, the first argument will contain the error. In case of success, the first argument will be null and the second argument will be a boolean indicating whether the value was stored.
let setItem: (
TelegramWebApp.CloudStorage.t,
string,
string,
~callback: (
Null.t<cloudStorageError>,
option<bool>,
) => unit=?,
) => TelegramWebApp.CloudStorage.tA method that receives a value from the cloud storage using the specified key. The key should contain 1-128 characters, only A-Z, a-z, 0-9, _ and - are allowed. In case of an error, the callback function will be called and the first argument will contain the error. In case of success, the first argument will be null and the value will be passed as the second argument.
let getItem: (
TelegramWebApp.CloudStorage.t,
string,
~callback: (
Null.t<cloudStorageError>,
option<string>,
) => unit,
) => TelegramWebApp.CloudStorage.tA method that receives values from the cloud storage using the specified keys. The keys should contain 1-128 characters, only A-Z, a-z, 0-9, _ and - are allowed. In case of an error, the callback function will be called and the first argument will contain the error. In case of success, the first argument will be null and the values will be passed as the second argument.
let getItems: (
TelegramWebApp.CloudStorage.t,
array<string>,
~callback: (
Null.t<cloudStorageError>,
option<array<string>>,
) => unit,
) => TelegramWebApp.CloudStorage.tlet removeItem: (
TelegramWebApp.CloudStorage.t,
string,
~callback: (
Null.t<cloudStorageError>,
option<bool>,
) => unit,
) => TelegramWebApp.CloudStorage.tA method that removes values from the cloud storage using the specified keys. The keys should contain 1-128 characters, only A-Z, a-z, 0-9, _ and - are allowed. If an optional callback parameter was passed, the callback function will be called. In case of an error, the first argument will contain the error. In case of success, the first argument will be null and the second argument will be a boolean indicating whether the values were removed.
let removeItems: (
TelegramWebApp.CloudStorage.t,
array<string>,
~callback: (
Null.t<cloudStorageError>,
option<bool>,
) => unit,
) => TelegramWebApp.CloudStorage.tA method that receives the list of all keys stored in the cloud storage. In case of an error, the callback function will be called and the first argument will contain the error. In case of success, the first argument will be null and the list of keys will be passed as the second argument.
let getKeys: (
TelegramWebApp.CloudStorage.t,
~callback: (
Null.t<cloudStorageError>,
option<array<string>>,
) => unit,
) => TelegramWebApp.CloudStorage.ttype t = {
isStarted: bool,
absolute: bool,
alpha: float,
beta: float,
gamma: float,
}type deviceOrientationStartParams = {
refresh_rate?: int,
need_absolute?: bool,
}Starts tracking device orientation data using params of type DeviceOrientationStartParams. If an optional callback parameter is provided, the callback function will be called with a boolean indicating whether tracking was successfully started.
let start: (
TelegramWebApp.DeviceOrientation.t,
deviceOrientationStartParams,
~callback: bool => unit=?,
) => TelegramWebApp.DeviceOrientation.tStops tracking device orientation data. If an optional callbackparameter is provided, the callback function will be called with a boolean indicating whether tracking was successfully stopped.
let stop: (
TelegramWebApp.DeviceOrientation.t,
~callback: bool => unit=?,
) => TelegramWebApp.DeviceOrientation.ttype t@unboxed
type deviceStorageError =
| @as("UNKNOWN_ERROR") UnknownError
| UndocumentedError(string)A method that stores a value in the device's local storage using the specified key. If an optional callback parameter was passed, the callback function will be called. In case of an error, the first argument will contain the error. In case of success, the first argument will be null and the second argument will be a boolean indicating whether the value was stored.
let setItem: (
TelegramWebApp.DeviceStorage.t,
string,
string,
~callback: (
Null.t<deviceStorageError>,
option<bool>,
) => unit=?,
) => TelegramWebApp.DeviceStorage.tA method that receives a value from the device's local storage using the specified key. In case of an error, the callback function will be called and the first argument will contain the error. In case of success, the first argument will be null and the value will be passed as the second argument.
let getItem: (
TelegramWebApp.DeviceStorage.t,
string,
~callback: (
Null.t<deviceStorageError>,
option<string>,
) => unit,
) => TelegramWebApp.DeviceStorage.tA method that removes a value from the device's local storage using the specified key. If an optional callback parameter was passed, the callbackfunction will be called. In case of an error, the first argument will contain the error. In case of success, the first argument will be null and the second argument will be a boolean indicating whether the value was removed.
let removeItem: (
TelegramWebApp.DeviceStorage.t,
string,
~callback: (
Null.t<deviceStorageError>,
option<bool>,
) => unit=?,
) => TelegramWebApp.DeviceStorage.tA method that clears all keys previously stored by the bot in the device's local storage. If an optional callback parameter was passed, the callbackfunction will be called. In case of an error, the first argument will contain the error. In case of success, the first argument will be null and the second argument will be a boolean indicating whether all values were removed.
let clear: (
TelegramWebApp.DeviceStorage.t,
~callback: (
Null.t<deviceStorageError>,
option<bool>,
) => unit=?,
) => TelegramWebApp.DeviceStorage.ttype t = {isStarted: bool, x: float, y: float, z: float}type gyroscopeStartParams = {refresh_rate?: int}Starts tracking gyroscope data using params of type GyroscopeStartParams. If an optional callback parameter is provided, the callbackfunction will be called with a boolean indicating whether tracking was successfully started.
let start: (
TelegramWebApp.Gyroscope.t,
gyroscopeStartParams,
~callback: bool => unit=?,
) => TelegramWebApp.Gyroscope.tStops tracking gyroscope data. If an optional callback parameter is provided, the callback function will be called with a boolean indicating whether tracking was successfully stopped.
let stop: (
TelegramWebApp.Gyroscope.t,
~callback: bool => unit=?,
) => TelegramWebApp.Gyroscope.ttype ttype impactStyle =
| @as("light") Light
| @as("medium") Medium
| @as("heavy") Heavy
| @as("rigid") Rigid
| @as("soft") SoftA method tells that an impact occurred. The Telegram app may play the appropriate haptics based on style value passed.
let impactOccurred: (TelegramWebApp.HapticFeedback.t, impactStyle) => unittype notificationType =
| @as("error") Error
| @as("success") Success
| @as("warning") WarningA method tells that a task or action has succeeded, failed, or produced a warning. The Telegram app may play the appropriate haptics based on type value passed.
let notificationOccurred: (TelegramWebApp.HapticFeedback.t, notificationType) => unitA method tells that the user has changed a selection. The Telegram app may play the appropriate haptics.
Do not use this feedback when the user makes or confirms a selection; use it only when the selection changes.
let selectionChanged: (TelegramWebApp.HapticFeedback.t, notificationType) => unittype t = {
isInited: bool,
isLocationAvailable: bool,
isAccessRequested: bool,
isAccessGranted: bool,
}type locationData = {
latitude: float,
longitude: float,
altitude: float,
course: float,
speed: float,
horizontal_accuracy: float,
vertical_accuracy: float,
course_accuracy: float,
speed_accuracy: float,
}A method that initializes the LocationManager object. It should be called before the object's first use. If an optional callback parameter is provided, the callback function will be called when the object is initialized.
let init: (
TelegramWebApp.LocationManager.t,
~callback: unit => unit=?,
) => TelegramWebApp.LocationManager.tA method that requests location data. The callback function will be called with null as the first argument if access to location was not granted, or an object of type LocationData as the first argument if access was successful.
let getLocation: (
TelegramWebApp.LocationManager.t,
~callback: TelegramWebApp.LocationManager.locationData => unit,
) => TelegramWebApp.LocationManager.tA method that opens the location access settings for bots. Useful when you need to request location access from users who haven't granted it yet.
Note that this method can be called only in response to user interaction with the Mini App interface (e.g., a click inside the Mini App or on the main button)."
let openSetting: TelegramWebApp.LocationManager.t => TelegramWebApp.LocationManager.ttype t@unboxed
type secureStorageError =
| @as("UNKNOWN_ERROR") UnknownError
| UndocumentedError(string)A method that stores a value in the device's secure storage using the specified key. If an optional callback parameter was passed, the callback function will be called. In case of an error, the first argument will contain the error. In case of success, the first argument will be null and the second argument will be a boolean indicating whether the value was stored.
let setItem: (
TelegramWebApp.SecureStorage.t,
string,
string,
~callback: (
Null.t<secureStorageError>,
option<bool>,
) => unit=?,
) => TelegramWebApp.SecureStorage.tA method that receives a value from the device's secure storage using the specified key. In case of an error, the callback function will be called and the first argument will contain the error. In case of success, the first argument will be null and the value will be passed as the second argument. If the key was not found, the second argument will be null, and the third argument will be a boolean indicating whether the key can be restored from the current device.
let getItem: (
TelegramWebApp.SecureStorage.t,
string,
~callback: (
Null.t<secureStorageError>,
option<string>,
) => unit,
) => TelegramWebApp.SecureStorage.tAttempts to restore a key that previously existed on the current device. When called, the user will be asked for permission to restore the value. If the user declines or an error occurs, the first argument in the callback will contain the error. If restored successfully, the first argument will be null and the second argument will contain the restored value.
let restoreItem: (
TelegramWebApp.SecureStorage.t,
string,
~callback: (
Null.t<secureStorageError>,
option<string>,
) => unit=?,
) => TelegramWebApp.SecureStorage.tA method that removes a value from the device's secure storage using the specified key. If an optional callback parameter was passed, the callbackfunction will be called. In case of an error, the first argument will contain the error. In case of success, the first argument will be null and the second argument will be a boolean indicating whether the value was removed.
let removeItem: (
TelegramWebApp.SecureStorage.t,
string,
~callback: (
Null.t<secureStorageError>,
option<bool>,
) => unit=?,
) => TelegramWebApp.SecureStorage.tA method that clears all keys previously stored by the bot in the device's secure storage. If an optional callback parameter was passed, the callbackfunction will be called. In case of an error, the first argument will contain the error. In case of success, the first argument will be null and the second argument will be a boolean indicating whether all values were removed.
let clear: (
TelegramWebApp.SecureStorage.t,
~callback: (
Null.t<secureStorageError>,
option<bool>,
) => unit=?,
) => TelegramWebApp.SecureStorage.ttype t = {mutable isVisible: bool}A method that sets the press event handler for the Settings item in the context menu. An alias for Telegram.WebApp.onEvent('settingsButtonClicked', callback)
let onClick: (
TelegramWebApp.SettingsButton.t,
~callback: unit => unit,
) => TelegramWebApp.SettingsButton.tA method that removes the press event handler from the Settings item in the context menu. An alias for Telegram.WebApp.offEvent('settingsButtonClicked', callback)
let offClick: (
TelegramWebApp.SettingsButton.t,
~callback: unit => unit,
) => TelegramWebApp.SettingsButton.tA method to make the Settings item in the context menu visible.
let show: TelegramWebApp.SettingsButton.t => TelegramWebApp.SettingsButton.tA method to hide the Settings item in the context menu.
let hide: TelegramWebApp.SettingsButton.t => TelegramWebApp.SettingsButton.t