pub struct TelegramWebApp { /* private fields */ }Expand description
Safe wrapper around window.Telegram.WebApp
Implementations§
Source§impl TelegramWebApp
impl TelegramWebApp
Set custom emoji icon for a bottom button (Bot API 9.5+).
Sets the custom emoji ID to be displayed as an icon on the button. Use an empty string to remove the icon.
§Arguments
button- The button to update (Main or Secondary)icon_id- The custom emoji ID (e.g., “123456789”)
§Errors
Returns JsValue if the underlying JS call fails.
§Examples
use telegram_webapp_sdk::webapp::{BottomButton, TelegramWebApp};
if let Some(app) = TelegramWebApp::instance() {
let _ = app.set_bottom_button_icon_custom_emoji_id(BottomButton::Main, "123456789");
}Enable a bottom button, allowing user interaction.
§Examples
use telegram_webapp_sdk::webapp::{BottomButton, TelegramWebApp};
if let Some(app) = TelegramWebApp::instance() {
let _ = app.enable_bottom_button(BottomButton::Main);
}Disable a bottom button, preventing user interaction.
§Examples
use telegram_webapp_sdk::webapp::{BottomButton, TelegramWebApp};
if let Some(app) = TelegramWebApp::instance() {
let _ = app.disable_bottom_button(BottomButton::Main);
}Show the circular loading indicator on a bottom button.
§Examples
use telegram_webapp_sdk::webapp::{BottomButton, TelegramWebApp};
if let Some(app) = TelegramWebApp::instance() {
let _ = app.show_bottom_button_progress(BottomButton::Main, false);
}Hide the loading indicator on a bottom button.
§Examples
use telegram_webapp_sdk::webapp::{BottomButton, TelegramWebApp};
if let Some(app) = TelegramWebApp::instance() {
let _ = app.hide_bottom_button_progress(BottomButton::Main);
}Returns whether the specified bottom button is currently visible.
§Examples
use telegram_webapp_sdk::webapp::{BottomButton, TelegramWebApp};
if let Some(app) = TelegramWebApp::instance() {
let _ = app.is_bottom_button_visible(BottomButton::Main);
}Returns whether the specified bottom button is active (enabled).
§Examples
use telegram_webapp_sdk::webapp::{BottomButton, TelegramWebApp};
if let Some(app) = TelegramWebApp::instance() {
let _ = app.is_bottom_button_active(BottomButton::Main);
}Returns whether the progress indicator is visible on the button.
§Examples
use telegram_webapp_sdk::webapp::{BottomButton, TelegramWebApp};
if let Some(app) = TelegramWebApp::instance() {
let _ = app.is_bottom_button_progress_visible(BottomButton::Main);
}Returns the current text displayed on the button.
§Examples
use telegram_webapp_sdk::webapp::{BottomButton, TelegramWebApp};
if let Some(app) = TelegramWebApp::instance() {
let _ = app.bottom_button_text(BottomButton::Main);
}Returns the current custom emoji icon ID of the button (Bot API 9.5+).
§Arguments
button- The button to query (Main or Secondary)
§Examples
use telegram_webapp_sdk::webapp::{BottomButton, TelegramWebApp};
if let Some(app) = TelegramWebApp::instance() {
if let Some(icon_id) = app.bottom_button_icon_custom_emoji_id(BottomButton::Main) {
println!("Icon ID: {}", icon_id);
}
}Returns the current text color of the button.
§Examples
use telegram_webapp_sdk::webapp::{BottomButton, TelegramWebApp};
if let Some(app) = TelegramWebApp::instance() {
let _ = app.bottom_button_text_color(BottomButton::Main);
}Returns the current background color of the button.
§Examples
use telegram_webapp_sdk::webapp::{BottomButton, TelegramWebApp};
if let Some(app) = TelegramWebApp::instance() {
let _ = app.bottom_button_color(BottomButton::Main);
}Returns whether the shine effect is enabled on the button.
§Examples
use telegram_webapp_sdk::webapp::{BottomButton, TelegramWebApp};
if let Some(app) = TelegramWebApp::instance() {
let _ = app.bottom_button_has_shine_effect(BottomButton::Main);
}Update bottom button state via setParams.
§Examples
use telegram_webapp_sdk::webapp::{BottomButton, BottomButtonParams, TelegramWebApp};
if let Some(app) = TelegramWebApp::instance() {
let params = BottomButtonParams {
text: Some("Send"),
..Default::default()
};
let _ = app.set_bottom_button_params(BottomButton::Main, ¶ms);
}Update secondary button state via setParams, including position.
§Examples
use telegram_webapp_sdk::webapp::{
SecondaryButtonParams, SecondaryButtonPosition, TelegramWebApp
};
if let Some(app) = TelegramWebApp::instance() {
let params = SecondaryButtonParams {
position: Some(SecondaryButtonPosition::Left),
..Default::default()
};
let _ = app.set_secondary_button_params(¶ms);
}Returns the configured position of the secondary button, if available.
§Examples
use telegram_webapp_sdk::webapp::{SecondaryButtonPosition, TelegramWebApp};
if let Some(app) = TelegramWebApp::instance() {
let _ = app.secondary_button_position();
}Set callback for onClick() on a bottom button.
Returns an EventHandle that can be used to remove the callback.
§Errors
Returns JsValue if the underlying JS call fails.
Registers a callback for the native back button.
Returns an EventHandle that can be passed to
remove_back_button_callback.
§Examples
let handle = app.set_back_button_callback(|| {}).expect("callback");
app.remove_back_button_callback(handle).unwrap();§Errors
Returns JsValue if the underlying JS call fails.
Registers a callback for the native settings button.
Returns an EventHandle that can be passed to
remove_settings_button_callback.
§Errors
Returns JsValue if the underlying JS call fails.
Returns whether the native settings button is visible.
Legacy alias for Self::show_bottom_button with
BottomButton::Main.
Legacy alias for Self::hide_bottom_button with
BottomButton::Main.
Legacy alias for Self::set_bottom_button_text with
BottomButton::Main.
Legacy alias for Self::set_bottom_button_color with
BottomButton::Main.
Legacy alias for Self::set_bottom_button_text_color with
BottomButton::Main.
Set custom emoji icon for the main button (Bot API 9.5+).
Legacy alias for Self::set_bottom_button_icon_custom_emoji_id with
BottomButton::Main.
§Examples
use telegram_webapp_sdk::webapp::TelegramWebApp;
if let Some(app) = TelegramWebApp::instance() {
let _ = app.set_main_button_icon_custom_emoji_id("123456789");
}Enable the main bottom button.
§Examples
use telegram_webapp_sdk::webapp::TelegramWebApp;
if let Some(app) = TelegramWebApp::instance() {
let _ = app.enable_main_button();
}Disable the main bottom button.
§Examples
use telegram_webapp_sdk::webapp::TelegramWebApp;
if let Some(app) = TelegramWebApp::instance() {
let _ = app.disable_main_button();
}Show progress on the main bottom button.
§Examples
use telegram_webapp_sdk::webapp::TelegramWebApp;
if let Some(app) = TelegramWebApp::instance() {
let _ = app.show_main_button_progress(false);
}Hide progress indicator from the main bottom button.
§Examples
use telegram_webapp_sdk::webapp::TelegramWebApp;
if let Some(app) = TelegramWebApp::instance() {
let _ = app.hide_main_button_progress();
}Update the main button state via
set_bottom_button_params.
Legacy alias for Self::set_bottom_button_callback with
BottomButton::Main.
Remove callback for the main button.
Legacy alias for Self::remove_bottom_button_callback.
Show the secondary bottom button.
Hide the secondary bottom button.
Set text for the secondary bottom button.
Set color for the secondary bottom button.
Set text color for the secondary bottom button.
Set custom emoji icon for the secondary button (Bot API 9.5+).
Convenience alias for Self::set_bottom_button_icon_custom_emoji_id
with BottomButton::Secondary.
§Examples
use telegram_webapp_sdk::webapp::TelegramWebApp;
if let Some(app) = TelegramWebApp::instance() {
let _ = app.set_secondary_button_icon_custom_emoji_id("123456789");
}Enable the secondary bottom button.
§Examples
use telegram_webapp_sdk::webapp::TelegramWebApp;
if let Some(app) = TelegramWebApp::instance() {
let _ = app.enable_secondary_button();
}Disable the secondary bottom button.
§Examples
use telegram_webapp_sdk::webapp::TelegramWebApp;
if let Some(app) = TelegramWebApp::instance() {
let _ = app.disable_secondary_button();
}Show progress on the secondary bottom button.
§Examples
use telegram_webapp_sdk::webapp::TelegramWebApp;
if let Some(app) = TelegramWebApp::instance() {
let _ = app.show_secondary_button_progress(false);
}Hide progress indicator from the secondary bottom button.
§Examples
use telegram_webapp_sdk::webapp::TelegramWebApp;
if let Some(app) = TelegramWebApp::instance() {
let _ = app.hide_secondary_button_progress();
}Set callback for the secondary bottom button.
Remove callback for the secondary bottom button.
Source§impl TelegramWebApp
impl TelegramWebApp
Sourcepub fn try_instance() -> Result<Self, JsValue>
pub fn try_instance() -> Result<Self, JsValue>
Sourcepub fn get_raw_init_data() -> Result<String, &'static str>
pub fn get_raw_init_data() -> Result<String, &'static str>
Returns the raw initData string as provided by Telegram.
This is the URL-encoded initData string captured during SDK initialization, suitable for server-side signature validation.
§Errors
Returns an error if the SDK has not been initialized via
crate::core::init::init_sdk.
§Examples
use telegram_webapp_sdk::TelegramWebApp;
match TelegramWebApp::get_raw_init_data() {
Ok(raw) => {
// Send to backend for validation
println!("Raw initData: {}", raw);
}
Err(e) => eprintln!("SDK not initialized: {}", e)
}Sourcepub fn is_version_at_least(&self, version: &str) -> Result<bool, JsValue>
pub fn is_version_at_least(&self, version: &str) -> Result<bool, JsValue>
Returns whether the WebApp version is at least the provided value.
§Examples
use telegram_webapp_sdk::webapp::TelegramWebApp;
if let Some(app) = TelegramWebApp::instance() {
let _ = app.is_version_at_least("9.0");
}Sourcepub fn invoke_custom_method_with_callback<F>(
&self,
method: &str,
params: &JsValue,
callback: F,
) -> Result<(), JsValue>
pub fn invoke_custom_method_with_callback<F>( &self, method: &str, params: &JsValue, callback: F, ) -> Result<(), JsValue>
Call WebApp.invokeCustomMethod(method, params, callback).
JS callback signature is (error, result). The Rust callback receives a
Result<JsValue, JsValue> — Ok(result) when JS passes
null/undefined for error, Err(err) otherwise.
Prefer the async sibling Self::invoke_custom_method for new code.
§Errors
Returns JsValue if the underlying JS call fails.
Sourcepub async fn invoke_custom_method(
&self,
method: &str,
params: &JsValue,
) -> Result<JsValue, JsValue>
pub async fn invoke_custom_method( &self, method: &str, params: &JsValue, ) -> Result<JsValue, JsValue>
Async wrapper over WebApp.invokeCustomMethod.
Resolves with the JS result value when Telegram returns a successful
response and rejects with the JS error value otherwise.
§Examples
let app = TelegramWebApp::try_instance()?;
let params = Object::new();
let result = app
.invoke_custom_method("getRequestedContact", ¶ms.into())
.await?;
let _ = result;§Errors
Returns JsValue if Telegram rejects the call or the underlying JS
invocation fails.
Source§impl TelegramWebApp
impl TelegramWebApp
Sourcepub fn show_confirm_with_callback<F>(
&self,
msg: &str,
on_confirm: F,
) -> Result<(), JsValue>
pub fn show_confirm_with_callback<F>( &self, msg: &str, on_confirm: F, ) -> Result<(), JsValue>
Sourcepub fn show_popup_with_callback<F>(
&self,
params: &JsValue,
callback: F,
) -> Result<(), JsValue>
pub fn show_popup_with_callback<F>( &self, params: &JsValue, callback: F, ) -> Result<(), JsValue>
Call WebApp.showPopup(params, callback).
§Examples
let params = Object::new();
app.show_popup_with_callback(¶ms.into(), |id| {
let _ = id;
})
.unwrap();Callback variant of Self::show_popup.
Sourcepub fn show_scan_qr_popup_with_callback<F>(
&self,
text: &str,
callback: F,
) -> Result<(), JsValue>
pub fn show_scan_qr_popup_with_callback<F>( &self, text: &str, callback: F, ) -> Result<(), JsValue>
Call WebApp.showScanQrPopup({ text }, callback).
The text is shown above the scanner viewport. Pass an empty string to open the scanner without a caption.
§Examples
app.show_scan_qr_popup_with_callback("Scan", |text| {
let _ = text;
})
.unwrap();Callback variant of Self::show_scan_qr_popup.
Source§impl TelegramWebApp
impl TelegramWebApp
Sourcepub fn on_event<F>(
&self,
event: &str,
callback: F,
) -> Result<EventHandle<dyn FnMut(JsValue)>, JsValue>
pub fn on_event<F>( &self, event: &str, callback: F, ) -> Result<EventHandle<dyn FnMut(JsValue)>, JsValue>
Register event handler (web_app_event_name, callback).
Returns an EventHandle that can be passed to
off_event.
§Errors
Returns JsValue if the underlying JS call fails.
Sourcepub fn on_background_event<F>(
&self,
event: BackgroundEvent,
callback: F,
) -> Result<EventHandle<dyn FnMut(JsValue)>, JsValue>
pub fn on_background_event<F>( &self, event: BackgroundEvent, callback: F, ) -> Result<EventHandle<dyn FnMut(JsValue)>, JsValue>
Register a callback for a background event.
Returns an EventHandle that can be passed to
off_event.
§Errors
Returns JsValue if the underlying JS call fails.
Sourcepub fn on_theme_changed<F>(
&self,
callback: F,
) -> Result<EventHandle<dyn FnMut()>, JsValue>where
F: 'static + Fn(),
pub fn on_theme_changed<F>(
&self,
callback: F,
) -> Result<EventHandle<dyn FnMut()>, JsValue>where
F: 'static + Fn(),
Register a callback for theme changes.
Returns an EventHandle that can be passed to
off_event.
§Errors
Returns JsValue if the underlying JS call fails.
Sourcepub fn on_safe_area_changed<F>(
&self,
callback: F,
) -> Result<EventHandle<dyn FnMut()>, JsValue>where
F: 'static + Fn(),
pub fn on_safe_area_changed<F>(
&self,
callback: F,
) -> Result<EventHandle<dyn FnMut()>, JsValue>where
F: 'static + Fn(),
Register a callback for safe area changes.
Returns an EventHandle that can be passed to
off_event.
§Errors
Returns JsValue if the underlying JS call fails.
Sourcepub fn on_content_safe_area_changed<F>(
&self,
callback: F,
) -> Result<EventHandle<dyn FnMut()>, JsValue>where
F: 'static + Fn(),
pub fn on_content_safe_area_changed<F>(
&self,
callback: F,
) -> Result<EventHandle<dyn FnMut()>, JsValue>where
F: 'static + Fn(),
Register a callback for content safe area changes.
Returns an EventHandle that can be passed to
off_event.
§Errors
Returns JsValue if the underlying JS call fails.
Sourcepub fn on_viewport_changed<F>(
&self,
callback: F,
) -> Result<EventHandle<dyn FnMut()>, JsValue>where
F: 'static + Fn(),
pub fn on_viewport_changed<F>(
&self,
callback: F,
) -> Result<EventHandle<dyn FnMut()>, JsValue>where
F: 'static + Fn(),
Register a callback for viewport changes.
Returns an EventHandle that can be passed to
off_event.
§Errors
Returns JsValue if the underlying JS call fails.
Sourcepub fn on_clipboard_text_received<F>(
&self,
callback: F,
) -> Result<EventHandle<dyn FnMut(JsValue)>, JsValue>
pub fn on_clipboard_text_received<F>( &self, callback: F, ) -> Result<EventHandle<dyn FnMut(JsValue)>, JsValue>
Register a callback for received clipboard text.
Returns an EventHandle that can be passed to
off_event.
§Errors
Returns JsValue if the underlying JS call fails.
Sourcepub fn on_invoice_closed<F>(
&self,
callback: F,
) -> Result<EventHandle<dyn FnMut(String)>, JsValue>
pub fn on_invoice_closed<F>( &self, callback: F, ) -> Result<EventHandle<dyn FnMut(String)>, JsValue>
Register a callback for invoice payment result.
Returns an EventHandle that can be passed to
off_event.
§Examples
let handle = app
.on_invoice_closed(|status| {
let _ = status;
})
.unwrap();
app.off_event(handle).unwrap();§Errors
Returns JsValue if the underlying JS call fails.
Source§impl TelegramWebApp
impl TelegramWebApp
Sourcepub fn close_with_options(&self, options: &CloseOptions) -> Result<(), JsValue>
pub fn close_with_options(&self, options: &CloseOptions) -> Result<(), JsValue>
Call WebApp.close(options) (Bot API 7.6+ for return_back).
On older Telegram clients the option is silently ignored on the JS side.
§Examples
app.close_with_options(&CloseOptions {
return_back: Some(true)
})
.unwrap();§Errors
Returns JsValue if the underlying JS call fails or the options fail
to serialize.
Sourcepub fn enable_closing_confirmation(&self) -> Result<(), JsValue>
pub fn enable_closing_confirmation(&self) -> Result<(), JsValue>
Sourcepub fn disable_closing_confirmation(&self) -> Result<(), JsValue>
pub fn disable_closing_confirmation(&self) -> Result<(), JsValue>
Sourcepub fn is_closing_confirmation_enabled(&self) -> bool
pub fn is_closing_confirmation_enabled(&self) -> bool
Returns whether closing confirmation is currently enabled.
§Examples
let _ = app.is_closing_confirmation_enabled();Sourcepub fn request_fullscreen(&self) -> Result<(), JsValue>
pub fn request_fullscreen(&self) -> Result<(), JsValue>
Sourcepub fn exit_fullscreen(&self) -> Result<(), JsValue>
pub fn exit_fullscreen(&self) -> Result<(), JsValue>
Sourcepub fn is_fullscreen(&self) -> bool
pub fn is_fullscreen(&self) -> bool
Returns whether the app is displayed in fullscreen mode.
§Examples
use telegram_webapp_sdk::webapp::TelegramWebApp;
if let Some(app) = TelegramWebApp::instance() {
let _ = app.is_fullscreen();
}Sourcepub fn unlock_orientation(&self) -> Result<(), JsValue>
pub fn unlock_orientation(&self) -> Result<(), JsValue>
Sourcepub fn is_orientation_locked(&self) -> bool
pub fn is_orientation_locked(&self) -> bool
Returns whether the orientation is locked.
§Examples
use telegram_webapp_sdk::webapp::TelegramWebApp;
if let Some(app) = TelegramWebApp::instance() {
let _ = app.is_orientation_locked();
}Sourcepub fn enable_vertical_swipes(&self) -> Result<(), JsValue>
pub fn enable_vertical_swipes(&self) -> Result<(), JsValue>
Sourcepub fn disable_vertical_swipes(&self) -> Result<(), JsValue>
pub fn disable_vertical_swipes(&self) -> Result<(), JsValue>
Sourcepub fn is_vertical_swipes_enabled(&self) -> bool
pub fn is_vertical_swipes_enabled(&self) -> bool
Returns whether vertical swipes are currently enabled.
§Examples
use telegram_webapp_sdk::webapp::TelegramWebApp;
if let Some(app) = TelegramWebApp::instance() {
let _ = app.is_vertical_swipes_enabled();
}Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Returns whether the mini app is currently active (visible to the user).
§Examples
use telegram_webapp_sdk::webapp::TelegramWebApp;
if let Some(app) = TelegramWebApp::instance() {
let _ = app.is_active();
}pub fn is_expanded(&self) -> bool
Source§impl TelegramWebApp
impl TelegramWebApp
Sourcepub fn open_link(
&self,
url: &str,
options: Option<&OpenLinkOptions>,
) -> Result<(), JsValue>
pub fn open_link( &self, url: &str, options: Option<&OpenLinkOptions>, ) -> Result<(), JsValue>
Sourcepub fn open_telegram_link(&self, url: &str) -> Result<(), JsValue>
pub fn open_telegram_link(&self, url: &str) -> Result<(), JsValue>
Call WebApp.openTelegramLink(url).
§Examples
app.open_telegram_link("https://t.me/telegram").unwrap();Sourcepub fn switch_inline_query(
&self,
query: &str,
choose_chat_types: Option<&JsValue>,
) -> Result<(), JsValue>
pub fn switch_inline_query( &self, query: &str, choose_chat_types: Option<&JsValue>, ) -> Result<(), JsValue>
Sourcepub fn request_chat_with_callback<F>(
&self,
req_id: i32,
callback: F,
) -> Result<(), JsValue>
pub fn request_chat_with_callback<F>( &self, req_id: i32, callback: F, ) -> Result<(), JsValue>
Callback variant of Self::request_chat (Bot API 9.6+).
§Errors
Returns JsValue if the underlying JS call fails.
Sourcepub async fn request_chat(&self, req_id: i32) -> Result<bool, JsValue>
pub async fn request_chat(&self, req_id: i32) -> Result<bool, JsValue>
Async wrapper over WebApp.requestChat (Bot API 9.6+). Resolves with
true when the user picks a chat, false on cancel/failure.
§Examples
let app = TelegramWebApp::try_instance()?;
let sent: bool = app.request_chat(42).await?;
let _ = sent;§Errors
Returns JsValue if the underlying JS call fails (including when the
running Telegram client predates Bot API 9.6).
Sourcepub fn add_to_home_screen(&self) -> Result<bool, JsValue>
pub fn add_to_home_screen(&self) -> Result<bool, JsValue>
Call WebApp.addToHomeScreen() and return whether the prompt was shown.
§Examples
let _shown = app.add_to_home_screen().unwrap();Sourcepub fn check_home_screen_status_with_callback<F>(
&self,
callback: F,
) -> Result<(), JsValue>
pub fn check_home_screen_status_with_callback<F>( &self, callback: F, ) -> Result<(), JsValue>
Callback variant of Self::check_home_screen_status.
Source§impl TelegramWebApp
impl TelegramWebApp
Sourcepub fn request_write_access_with_callback<F>(
&self,
callback: F,
) -> Result<(), JsValue>
pub fn request_write_access_with_callback<F>( &self, callback: F, ) -> Result<(), JsValue>
Callback variant of Self::request_write_access.
§Errors
Returns JsValue if the underlying JS call fails.
Sourcepub async fn request_write_access(&self) -> Result<bool, JsValue>
pub async fn request_write_access(&self) -> Result<bool, JsValue>
Async wrapper over WebApp.requestWriteAccess.
Resolves with true when the user grants permission to receive
messages from the bot.
§Examples
let app = TelegramWebApp::try_instance()?;
let granted: bool = app.request_write_access().await?;
let _ = granted;§Errors
Returns JsValue if the underlying JS call fails.
Sourcepub fn request_emoji_status_access_with_callback<F>(
&self,
callback: F,
) -> Result<(), JsValue>
pub fn request_emoji_status_access_with_callback<F>( &self, callback: F, ) -> Result<(), JsValue>
Callback variant of Self::request_emoji_status_access.
§Errors
Returns JsValue if the underlying JS call fails.
Sourcepub async fn request_emoji_status_access(&self) -> Result<bool, JsValue>
pub async fn request_emoji_status_access(&self) -> Result<bool, JsValue>
Sourcepub fn set_emoji_status_with_callback<F>(
&self,
status: &JsValue,
callback: F,
) -> Result<(), JsValue>
pub fn set_emoji_status_with_callback<F>( &self, status: &JsValue, callback: F, ) -> Result<(), JsValue>
Callback variant of Self::set_emoji_status.
§Errors
Returns JsValue if the underlying JS call fails.
Sourcepub fn open_invoice_with_callback<F>(
&self,
url: &str,
callback: F,
) -> Result<(), JsValue>
pub fn open_invoice_with_callback<F>( &self, url: &str, callback: F, ) -> Result<(), JsValue>
Callback variant of Self::open_invoice.
Sourcepub fn download_file_with_callback<F>(
&self,
params: DownloadFileParams<'_>,
callback: F,
) -> Result<(), JsValue>
pub fn download_file_with_callback<F>( &self, params: DownloadFileParams<'_>, callback: F, ) -> Result<(), JsValue>
Callback variant of Self::download_file.
§Errors
Returns JsValue if the underlying JS call fails or the parameters
fail to serialize.
Sourcepub async fn download_file(
&self,
params: DownloadFileParams<'_>,
) -> Result<String, JsValue>
pub async fn download_file( &self, params: DownloadFileParams<'_>, ) -> Result<String, JsValue>
Sourcepub fn read_text_from_clipboard_with_callback<F>(
&self,
callback: F,
) -> Result<(), JsValue>
pub fn read_text_from_clipboard_with_callback<F>( &self, callback: F, ) -> Result<(), JsValue>
Callback variant of Self::read_text_from_clipboard.
§Errors
Returns JsValue if the underlying JS call fails.
Source§impl TelegramWebApp
impl TelegramWebApp
Sourcepub fn color_scheme(&self) -> Option<String>
pub fn color_scheme(&self) -> Option<String>
Returns WebApp.colorScheme — "light" or "dark".
Sourcepub fn header_color(&self) -> Option<String>
pub fn header_color(&self) -> Option<String>
Returns the current WebApp.headerColor value.
Sourcepub fn background_color(&self) -> Option<String>
pub fn background_color(&self) -> Option<String>
Returns the current WebApp.backgroundColor value.
Sourcepub fn bottom_bar_color(&self) -> Option<String>
pub fn bottom_bar_color(&self) -> Option<String>
Returns the current WebApp.bottomBarColor value (Bot API 7.10+).
Sourcepub fn raw_version(&self) -> Option<String>
pub fn raw_version(&self) -> Option<String>
Returns the raw WebApp.version string (e.g. "9.6").
Sourcepub fn platform(&self) -> Option<String>
pub fn platform(&self) -> Option<String>
Returns the WebApp.platform string (e.g. "tdesktop", "ios",
"web").
Source§impl TelegramWebApp
impl TelegramWebApp
Sourcepub fn viewport_height(&self) -> Option<f64>
pub fn viewport_height(&self) -> Option<f64>
Sourcepub fn viewport_width(&self) -> Option<f64>
pub fn viewport_width(&self) -> Option<f64>
Sourcepub fn viewport_stable_height(&self) -> Option<f64>
pub fn viewport_stable_height(&self) -> Option<f64>
Sourcepub fn expand_viewport(&self) -> Result<(), JsValue>
pub fn expand_viewport(&self) -> Result<(), JsValue>
Sourcepub fn safe_area_inset(&self) -> Option<SafeAreaInset>
pub fn safe_area_inset(&self) -> Option<SafeAreaInset>
Returns the safe area insets reported by Telegram.
§Examples
use telegram_webapp_sdk::webapp::TelegramWebApp;
if let Some(app) = TelegramWebApp::instance() {
let _ = app.safe_area_inset();
}Sourcepub fn content_safe_area_inset(&self) -> Option<SafeAreaInset>
pub fn content_safe_area_inset(&self) -> Option<SafeAreaInset>
Returns the content safe area insets reported by Telegram.
§Examples
use telegram_webapp_sdk::webapp::TelegramWebApp;
if let Some(app) = TelegramWebApp::instance() {
let _ = app.content_safe_area_inset();
}Trait Implementations§
Source§impl Clone for TelegramWebApp
impl Clone for TelegramWebApp
Source§fn clone(&self) -> TelegramWebApp
fn clone(&self) -> TelegramWebApp
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more