{"id":427484,"date":"2024-07-26T15:00:06","date_gmt":"2024-07-26T15:00:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=427484"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=427484","title":{"rendered":"<span>\u0427\u0430\u0441\u0442\u044c 2. TMA \u043d\u0430 KMP. \u041f\u0438\u0448\u0435\u043c \u043a\u043b\u0438\u043a\u0435\u0440 \u0434\u043b\u044f Telegram<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/26f\/b1b\/a12\/26fb1ba12fe756bd5340b24220aecd12.png\" width=\"2160\" height=\"1200\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/26f\/b1b\/a12\/26fb1ba12fe756bd5340b24220aecd12.png\"\/><\/figure>\n<h2>\u041d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f \u043f\u043e \u0446\u0438\u043a\u043b\u0443 \u0441\u0442\u0430\u0442\u0435\u0439:<\/h2>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/830120\/\" rel=\"noopener noreferrer nofollow\">\u0427\u0430\u0441\u0442\u044c 1. \u041f\u0438\u0448\u0435\u043c \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043a\u043b\u0438\u043a\u0435\u0440 \u043d\u0430 Kotlin<\/a><br \/>\u0427\u0430\u0441\u0442\u044c 2. \u041f\u0438\u0448\u0435\u043c \u043a\u043b\u0438\u043a\u0435\u0440 \u0434\u043b\u044f Telegram \u043d\u0430 Kotlin \u2013 \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f<br \/>\u0427\u0430\u0441\u0442\u044c 2 \u0441 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u043e\u0439. \u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 rest-framework. TMA \u043d\u0430 KMP \u2013 \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435<br \/>\u0427\u0430\u0441\u0442\u044c 3. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u043f\u043b\u0430\u0442\u0443 \u0447\u0435\u0440\u0435\u0437 Telegram Mini Apps \u043d\u0430 Kotlin \u2013 \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435<\/p>\n<h2>\u0420\u0430\u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u0442\u0435\u043c\u044b \u0432 \u0446\u0438\u043a\u043b\u0435<\/h2>\n<ul>\n<li>\n<p>Web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 Kotlin \u2013 \u0447\u0430\u0441\u0442\u044c 1<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 Telegram Mini Apps \u2013 \u0447\u0430\u0441\u0442\u044c 2<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 TMA \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0422\u0435\u043c\u0430,\u00a0<code>MainButton<\/code>,\u00a0<code>BackButton<\/code>\u00a0\u2013 \u0447\u0430\u0441\u0442\u044c 2<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 Telegram. \u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 \u0441\u0441\u044b\u043b\u043a\u0443 \u2013 \u0447\u0430\u0441\u0442\u044c 2<\/p>\n<\/li>\n<li>\n<p>\u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 TMA \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u2013 \u0447\u0430\u0441\u0442\u044c 2 \u0438 2.5<\/p>\n<\/li>\n<li>\n<p>Telegram Payments API\u2013 \u0447\u0430\u0441\u0442\u044c 3<\/p>\n<\/li>\n<\/ul>\n<h2>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 Telegram<\/h2>\n<p>Telegram Mini Apps (\u0434\u0430\u043b\u0435\u0435 &#8212; TMA), \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e, \u0442\u043e \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a API, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0439 Telegram. \u0418\u0437 \u0447\u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0441\u0442\u0435\u043a, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439 \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0435 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 Telegram<\/p>\n<p>\u0414\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 Telegram \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0431\u043e\u0442\u0430 \u0447\u0435\u0440\u0435\u0437 BotFather \u043f\u043e\u00a0<a href=\"https:\/\/core.telegram.org\/bots#how-do-i-create-a-bot\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>. \u0421\u0430\u043c \u0442\u043e\u043a\u0435\u043d \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f, \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0431\u043e\u0442\u0430 \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0412 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u0431\u043e\u0442\u0430 (\u0432 \u0447\u0430\u0442\u0435 \u0441 BotFather) \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043c\u0435\u043d\u044e\u00a0<code>Bot Settings<\/code>\u00a0&gt;&gt;\u00a0<code>Menu Button<\/code>\u00a0&gt;&gt;\u00a0<code>Customize menu button<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0441 \u043f\u0440\u043e\u0441\u044f\u0442 \u0432\u0432\u0435\u0441\u0442\u0438 \u0441\u0441\u044b\u043b\u043a\u0443, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0448 \u0431\u043e\u0442.<\/p>\n<blockquote>\n<p><code>localhost<\/code>\u00a0\u043d\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0443 \u0432\u0430\u0441 \u043e\u043d \u043d\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 \u043f\u0440\u0438\u0451\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e https. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0434\u0451\u043c \u043f\u043e \u0441\u0430\u043c\u043e\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u043e\u043c\u0443 \u043f\u0443\u0442\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u00a0<code>ngrok<\/code>. \u0414\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u0441\u0430\u0439\u0442\u0435\u00a0<a href=\"https:\/\/ngrok.com\/\" rel=\"noopener noreferrer nofollow\">ngrok<\/a>, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0435\u0433\u043e \u0438 \u043f\u0440\u043e\u0439\u0434\u0438\u0442\u0435 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443. \u0421\u0430\u043c \u0437\u0430\u043f\u0443\u0441\u043a, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u0442\u0430\u043f, \u043f\u0440\u043e\u0441\u0442:<\/p>\n<\/blockquote>\n<pre><code class=\"bash\">ngrok http http:\/\/localhost:8080 --host-header=\"localhost:8080\"<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0445\u043e\u0441\u0442, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0441 https \u0441\u0445\u0435\u043c\u043e\u0439<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0ee\/437\/1f4\/0ee4371f465cec7d6d491664f874f7b3.png\" alt=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 2\" title=\"\" width=\"468\" height=\"32\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0ee\/437\/1f4\/0ee4371f465cec7d6d491664f874f7b3.png\"\/><\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u0432 BotFather \u0438 \u0437\u0430\u0434\u0430\u0451\u043c \u043d\u0430\u0434\u043f\u0438\u0441\u044c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0435. \u0413\u043e\u0442\u043e\u0432\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0432\u0435\u0436\u0435\u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0431\u043e\u0442\u0430 \u0435\u0441\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0430. \u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0448\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<h2>\u041d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c TMA (MainButton, BackButton)<\/h2>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u044d\u043a\u0440\u0430\u043d, \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c enum, state \u0438 when.<\/p>\n<pre><code class=\"kotlin\">\/\/ Don't use in real code enum class Screen {     CLICKER,     FRIENDS_LIST, }  \/\/ Don't use in real code var currentScreen by mutableStateOf(Screen.CLICKER)  @Composable fun App() {     when (currentScreen) {         Screen.CLICKER -&gt; ClickerScreen(             onFriendsList = {                 currentScreen = Screen.FRIENDS_LIST             }         )          Screen.FRIENDS_LIST -&gt; FriendsListScreen(             onBack = {                 currentScreen = Screen.CLICKER             },         )     } }<\/code><\/pre>\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u043d\u0435\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u043b\u0441\u044f \u0432\u00a0<code>App()<\/code>\u0432\u044b\u043d\u043e\u0441\u0438\u043c \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u044d\u043a\u0440\u0430\u043d \u0441 callback \u043d\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u044d\u043a\u0440\u0430\u043d<\/p>\n<pre><code class=\"kotlin\">val score = mutableStateOf(0L)  @Composable fun ClickerScreen(     onFriendsList: () -&gt; Unit, ) {     Div(         attrs = {             classes(ClickerStyles.MainContainer)         }     ) {         Div(             attrs = {                 classes(ClickerStyles.ClickerBlock)             }         ) {             H2 {                 Text(\"Score: ${score.value}\")             }             Img(                 src = Res.images.click_item.fileUrl,                 attrs = {                     classes(ClickerStyles.MainImage)                     onClick {                         score.value += 1                     }                 }             )         }     } }<\/code><\/pre>\n<p>\u0412\u0442\u043e\u0440\u044b\u043c \u044d\u043a\u0440\u0430\u043d\u043e\u043c \u0441\u0442\u0430\u043d\u0435\u0442 \u0441\u0430\u043c\u0430\u044f \u0432\u0430\u0436\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u043a\u043b\u0438\u043a\u0435\u0440\u043e\u0432 \u2013 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0440\u0443\u0437\u0435\u0439. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0442\u044c \u0438\u0445 \u0432 \u043d\u0430\u0448\u0443 \u0438\u0433\u0440\u0443 \u0447\u0435\u0440\u0435\u0437 \u0441\u0441\u044b\u043b\u043a\u0443.<\/p>\n<pre><code class=\"kotlin\">@Composable fun FriendsListScreen(     onBack: () -&gt; Unit, ) {     Div(         attrs = {             classes(FriendsListStyle.Container)         }     ) {         H4 {             Text(\"\u0423 \u0442\u0435\u0431\u044f \u043f\u043e\u043a\u0430 \u043d\u0435\u0442 \u0434\u0440\u0443\u0437\u0435\u0439...\")         }     }  }<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u044d\u043a\u0440\u0430\u043d\u044b, \u043d\u043e \u043f\u043e \u043d\u0438\u043c \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 Telegram: \u044d\u0442\u043e\u00a0<code>MainButton<\/code>\u00a0\u0438\u00a0<code>BackButton<\/code>.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0430\u043c TMA API \u0432 \u043d\u0430\u0448\u0435 \u0432\u0435\u0431 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0439, \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u043e\u0439 \u043e\u0431\u0451\u0440\u0442\u043a\u043e\u0439 \u043d\u0430\u0434 JS \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 TMA<\/p>\n<pre><code class=\"kotlin\">jsMain.dependencies {     \/\/\u2026     implementation(\"dev.inmo:tgbotapi.webapps:15.0.0\") }<\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u044d\u0442\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0432\u0440\u0430\u043f\u0435\u0440\u043e\u043c \u0434\u043b\u044f API \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c, \u0432 \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c js \u0432\u0435\u0440\u0441\u0438\u044e TMA API. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0451 \u043a\u0430\u043a\u00a0<code>script<\/code>\u00a0\u0432\u00a0<code>index.html<\/code>\u00a0\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435.<\/p>\n<pre><code class=\"xml\">&lt;head&gt;     ...     &lt;script src=\"https:\/\/telegram.org\/js\/telegram-web-app.js\"&gt;&lt;\/script&gt; &lt;\/head&gt;<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u00a0<code>webApp<\/code>,\u00a0\u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u044f\u00a0<code>backButton<\/code>\u00a0\u0438\u00a0<code>mainButton<\/code>.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u043e\u044f\u0432\u0438\u043c \u0441\u043c\u0435\u043a\u0430\u043b\u043a\u0443 \u0438 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u0443\u0435\u043c \u0438\u0445 \u043f\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437 composable \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u2013 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0438\u0437 \u043d\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b.<\/p>\n<pre><code class=\"kotlin\">@Composable fun WebAppMainButton(     text: String,     onClick: () -&gt; Unit,     visible: Boolean = true,     active: Boolean? = undefined,     loading: Boolean = false,     loadingLeaveActive: Boolean = false,     hideOnDispose: Boolean = true, \/\/ use if next screen has MainButton too     color: String? = undefined,     textColor: String? = undefined, ) {     DisposableEffect(visible) {         if (visible) {             webApp.mainButton.show()         } else {             webApp.mainButton.hide()         }         onDispose {             if (hideOnDispose)                 webApp.mainButton.hide()         }     }     DisposableEffect(         keys = arrayOf(             onClick, text, color, textColor, visible, active,             loading, loadingLeaveActive         ),     ) {         webApp.mainButton.onClick(onClick)         webApp.mainButton.setParams(             MainButtonParams(                 text = text,                 color = color,                 textColor = textColor,                 isActive = active,                 isVisible = visible,             )         )         if (loading)             webApp.mainButton.showProgress(leaveActive = loadingLeaveActive)         else             webApp.mainButton.hideProgress()         onDispose {             webApp.mainButton.offClick(onClick)         }     } }  @Composable fun WebAppBackButton(     onClick: () -&gt; Unit, ) {     DisposableEffect(Unit) {         webApp.backButton.onClick(onClick)         webApp.backButton.show()         onDispose {             webApp.backButton.hide()             webApp.backButton.offClick(onClick)         }     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0449\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 TMA API. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u043a\u043d\u043e\u043f\u043a\u0443 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0440\u0443\u0437\u0435\u0439 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u043a\u043b\u0438\u043a\u0435\u0440\u0430, \u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u0440\u0443\u0437\u0435\u0439 \u043a\u043d\u043e\u043f\u043a\u0443 \u043d\u0430\u0437\u0430\u0434.<\/p>\n<pre><code class=\"kotlin\">@Composable fun FriendsListScreen(     onBack: () -&gt; Unit, ) {     WebAppBackButton(onClick = onBack)     \/\/ ... }  @Composable fun ClickerScreen(     onFriendsList: () -&gt; Unit, ) {     WebAppMainButton(         text = \"\u0421\u043f\u0438\u0441\u043e\u043a \u0434\u0440\u0443\u0437\u0435\u0439\",         hideOnDispose = false,         onClick = onFriendsList     )     \/\/ ... }<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d8e\/7c2\/c16\/d8e7c2c1618648843b674cf0dd07ceed.png\" alt=\"image.png\" title=\"\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0438\u043a\u043e\u043d\u043a\u043e\u0439 \u0434\u043b\u044f \u0442\u0430\u043f\u0430 \u0438 \u0437\u0430\u0441\u043a\u0440\u0438\u043d\u0438\u0442\u044c \u0437\u0430\u043d\u043e\u0432\u043e  \" width=\"856\" height=\"672\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d8e\/7c2\/c16\/d8e7c2c1618648843b674cf0dd07ceed.png\"\/><\/p>\n<div><figcaption><em>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0438\u043a\u043e\u043d\u043a\u043e\u0439 \u0434\u043b\u044f \u0442\u0430\u043f\u0430 \u0438 \u0437\u0430\u0441\u043a\u0440\u0438\u043d\u0438\u0442\u044c \u0437\u0430\u043d\u043e\u0432\u043e<\/em>  <\/figcaption><\/div>\n<\/figure>\n<h2>\u0422\u0435\u043c\u0430 \u043a\u0430\u043a \u0443 Telegram<\/h2>\n<p>\u0426\u0432\u0435\u0442\u0430 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u0438\u043b\u044c\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f, \u043d\u043e TMA API \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0432\u043e\u0438 \u0446\u0432\u0435\u0442\u0430 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u0445 \u0432 \u0441\u0432\u043e\u0451\u043c CSS. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0436\u0435 \u044d\u0442\u0438 \u0441\u0442\u0438\u043b\u0438 \u043a \u0441\u0435\u0431\u0435 \u0447\u0435\u0440\u0435\u0437 CSS in Kotlin. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c AppStyles, \u0433\u0434\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u044d\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f css variables<\/p>\n<pre><code class=\"kotlin\">object TMAVariables {     val BackgroundColorValue = Color(\"#ffffff\")     val BackgroundColor by variable&lt;CSSColorValue&gt;()     val SecondaryBackgroundColorValue = Color(\"#ffffff\")     val SecondaryBackgroundColor by variable&lt;CSSColorValue&gt;()     val TextColorValue = Color(\"#000000\")     val TextColor by variable&lt;CSSColorValue&gt;()     val HintColorValue = Color.gray     val HintColor by variable&lt;CSSColorValue&gt;()     \/\/ \u0418 \u0442. \u0434., \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 github }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u00a0<code>ThemeParams<\/code>, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0433\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0434\u043b\u044f\u00a0<code>StyleScope<\/code>. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e\u043b\u044f \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c null, \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 variable.<\/p>\n<pre><code class=\"kotlin\">fun StyleScope.applyThemeVariables(theme: ThemeParams) {     BackgroundColor(theme.backgroundColor?.toCSSColorValue() ?: BackgroundColorValue)     SecondaryBackgroundColor(theme.secondaryBackgroundColor?.toCSSColorValue() ?: SecondaryBackgroundColorValue)     TextColor(theme.textColor?.toCSSColorValue() ?: TextColorValue)     HintColor(theme.hintColor?.toCSSColorValue() ?: HintColorValue)     \/\/ \u0418 \u0442. \u0434., \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 github }<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u0443\u044e, \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441\u0442\u0438\u043b\u0435\u0439, \u0433\u0434\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 CSS variables \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0442\u0435\u0433\u043e\u0432.<\/p>\n<pre><code class=\"kotlin\">class AppStyles(val themeParams: ThemeParams) : StyleSheet() {     init {         \"body\" style {             applyThemeVariables(themeParams)             backgroundColor(TMAVariables.BackgroundColor.value())             color(TMAVariables.TextColor.value())         }         \"a\" style {             color(TMAVariables.LinkColor.value())         }         \"button\" style {             color(TMAVariables.ButtonTextColor.value())             backgroundColor(TMAVariables.ButtonColor.value())         }     } }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u0442\u0438\u043b\u044c \u0432\u00a0<code>renderComposable<\/code>, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0442\u0435\u043c\u044b\u00a0<code>webApp.themeParams<\/code><\/p>\n<pre><code class=\"kotlin\">renderComposable(rootElementId = \"app\") {     Style(AppStyles(webApp.themeParams))     \/\/ ... }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0438 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0446\u0432\u0435\u0442\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0447\u0435\u0442\u0430\u044e\u0442\u0441\u044f \u0441 Telegram<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/684\/1b7\/0e4\/6841b70e4d5f2c5ed3af87ca7bb8ebad.png\" width=\"420\" height=\"672\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/684\/1b7\/0e4\/6841b70e4d5f2c5ed3af87ca7bb8ebad.png\"\/><\/figure>\n<h2>\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>\u041a\u0440\u0430\u0442\u043a\u0430\u044f \u0441\u043f\u0440\u0430\u0432\u043a\u0430: \u043a\u0430\u0436\u0434\u044b\u0439 TMA \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0441 query params, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f id \u0438 \u043a\u0440\u0430\u0442\u043a\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041e\u043d\u0438 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043f\u043e\u043b\u044f\u0445\u00a0<code>webApp.initData<\/code>\u00a0\u0438\u00a0<code>webApp.initDataUnsafe<\/code>. \u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u2013 \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e initData \u2013 \u044d\u0442\u043e \u0441\u044b\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f\u00a0<a href=\"https:\/\/core.telegram.org\/bots\/webapps#validating-data-received-via-the-mini-app\" rel=\"noopener noreferrer nofollow\">\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438<\/a>,\u00a0<code>initDataUnsafe<\/code>\u00a0\u2013 \u044d\u0442\u043e type-safe \u043e\u0431\u044a\u0435\u043a\u0442, \u0433\u0434\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0443\u0436\u0435 \u0432 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435, \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0435 \u043d\u0438\u043a\u0430\u043a \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, username \u0438\u043b\u0438 id.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a5b\/7ba\/ae7\/a5b7baae754a615166c5064baf2ee753.png\" alt=\"image.png\" width=\"420\" height=\"672\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a5b\/7ba\/ae7\/a5b7baae754a615166c5064baf2ee753.png\"\/><\/p>\n<div><figcaption>image.png<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441\u00a0<code>webApp.initData<\/code>.\u00a0<code>TapClient<\/code>\u00a0\u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0432 commonMain \u0438 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c.<\/p>\n<pre><code class=\"kotlin\">object TapClient {     private val client: HttpClient = HttpClient(TapClientEngine) {         \/\/ \u2026         authConfig()     }      suspend fun sendCurrentScore(score: Long) {         client.post(\"\/score\") {             setBody(SendCurrentScoreRequest(score))             contentType(ContentType.Application.Json)         }     }      suspend fun fetchCurrentScore(): Long {         return client.get(\"\/score\").body&lt;GetCurrentScoreResponse&gt;().score     }      suspend fun fetchFriendsList(): List&lt;FriendInfo&gt; {         return client.get(\"\/friends\").body&lt;GetFriendsListResponse&gt;().friends     } } <\/code><\/pre>\n<p>\u0413\u0434\u0435\u00a0<code>authConfig()<\/code>\u00a0\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d \u043a\u0430\u043a\u00a0<code>expect<\/code>\u00a0\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u0445\u00a0<code>jsMain<\/code><\/p>\n<pre><code class=\"kotlin\">actual fun HttpClientConfig&lt;HttpClientEngineConfig&gt;.authConfig() {     defaultRequest {         header(\"tma-data\", webApp.initData)     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0438\u0437 Telegram \u0441 \u0432\u0435\u0440\u043d\u044b\u043c\u0438 \u0434\u044b\u043d\u043d\u044b\u043c\u0438. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u043f\u0440\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 (<em>\u0441\u0442\u0430\u0442\u044c\u044f \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435<\/em>).<\/p>\n<h2>\u041f\u0440\u044f\u043c\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438, \u043f\u043e\u0437\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0430<\/h2>\n<p>Direct link \u2013 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c TMA \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0441 \u043f\u0440\u0435\u0434\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438.<\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u044f\u043c\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a BotFather \u0438 \u043f\u0438\u0448\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443\u00a0<code>\/newapp<\/code>, \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u0438 \u0434\u0430\u043b\u0435\u0435<\/p>\n<ul>\n<li>\n<p>\u0437\u0430\u0434\u0430\u0451\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e TMA \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u0440\u043e\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e 640&#215;360.<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c GIF<\/p>\n<\/li>\n<li>\n<p>\u0421\u0441\u044b\u043b\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c (\u0442\u0430\u043a\u0430\u044f \u0436\u0435 \u0447\u0442\u043e, \u043c\u044b \u0437\u0430\u0434\u0430\u0432\u0430\u043b\u0438 \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043a\u043d\u043e\u043f\u043a\u0438 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438)<\/p>\n<\/li>\n<li>\n<p>appname, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u00a0<a href=\"https:\/\/t.me\/botusername\/appname\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>\u00a0\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u0430\u043a query \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441 \u043a\u043b\u044e\u0447\u0451\u043c\u00a0<a href=\"https:\/\/t.me\/botusername\/appname?startapp=mydata\" rel=\"noopener noreferrer nofollow\">startapp<\/a>. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0440\u044f\u043c\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u0432\u00a0<code>webApp.initDataUnsafe.startParam<\/code>.\u00a0\u0422\u0430\u043a \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u0440\u0443\u0437\u0435\u0439.<\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043d\u043e\u043f\u043a\u0443 \u043d\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0441\u0441\u044b\u043b\u043a\u0435 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0441 \u0434\u0440\u0443\u0437\u044c\u044f\u043c\u0438. \u042d\u0442\u043e \u043b\u0438\u0448\u044c \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f TMA API \u0438 \u043b\u0443\u0447\u0448\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0412\u044b\u0437\u043e\u0432\u00a0<code>buildInviteLink()<\/code>\u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0441\u0441\u044b\u043b\u043a\u0443, \u043f\u0435\u0440\u0435\u0439\u0434\u044f \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0448\u0435 TMA \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0430\u00a0<code>buildShareLink()<\/code>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 Telegram \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0433\u043e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434.<\/p>\n<pre><code class=\"kotlin\">\/\/ Use build config instead private const val AppLink = \"https:\/\/t.me\/botusername\/appname\" private const val ShareMessage = \"%D0%9F%D0%BE%D0%BF%D1%80%D0%BE%D0%B1%D1%83%D0%B9+%D1%8D%D1%82%D0%BE%D1%82+%D0%BD%D0%BE%D0%B2%D1%8B%D0%B9+%D0%BA%D0%BB%D0%B8%D0%BA%D0%B5%D1%80%21\"  private fun buildInviteLink(telegramId: Long): String {     return \"$AppLink?startapp=ref_$telegramId\" }  private fun buildShareLink(telegramId: Long): String {     return \"https:\/\/t.me\/share\/url?url=${buildInviteLink(telegramId)}&amp;text=${ShareMessage}\" }<\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c\u00a0<code>MainButton<\/code>, \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0435\u0451 \u0447\u0435\u0440\u0435\u0437\u00a0<code>webApp.openTelegramLink()<\/code>. Telegram \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435\u043c \u044d\u043a\u0440\u0430\u043d\u0430 \u201c\u043f\u0435\u0440\u0435\u0441\u043b\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u201c<\/p>\n<pre><code class=\"kotlin\">@Composable  fun FriendsListScreen(     onBack: () -&gt; Unit, ) {     WebAppMainButton(         text = \"\u041f\u0440\u0438\u0433\u043b\u0430\u0441\u0438\u0442\u044c \u0434\u0440\u0443\u0437\u0435\u0439\",         onClick = {             val id = webApp.initDataUnsafe.user?.id ?: return@WebAppMainButton             webApp.openTelegramLink(buildShareLink(id.long))         }     )     \/\/... }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e \u044d\u0442\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441\u043e \u0441\u0441\u044b\u043b\u043a\u043e\u0439-\u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435\u043c \u043b\u044e\u0431\u043e\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 (\u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0435\u0433\u043e \u043f\u0440\u0438\u0433\u043b\u0430\u0441\u0438\u043b\u0438) \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0442\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432\u0441\u0435 initData \u043e\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c.<\/p>\n<h2>\u0418\u0442\u043e\u0433\u0438<\/h2>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c TMA API \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043d\u0430 Kotlin. \u0421\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u2013 \u044d\u0442\u043e \u0441\u0442\u0438\u043b\u0438, \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0438 \u043a\u0430\u043a\u043e\u0435-\u043d\u0438\u043a\u0430\u043a\u043e\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c Telegram \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442, \u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438, \u0447\u0442\u043e \u0437\u0430\u0445\u043e\u0447\u0435\u0442 \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a. \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0432\u0435\u0442\u043a\u0435\u00a0<code>clicker<\/code>\u00a0\u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u00a0<a href=\"https:\/\/github.com\/ellow-tech\/kmp-compose-html-template\/tree\/clicker\" rel=\"noopener noreferrer nofollow\">\u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c \u043d\u0430 GitHub<\/a><\/p>\n<p>\u041c\u044b \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u043b\u0438\u043c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0432 \u0441\u0442\u0430\u0442\u044c\u044f\u0445, \u043d\u043e \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0432\u043e \u0431\u043b\u0430\u0433\u043e \u0431\u0438\u0437\u043d\u0435\u0441\u0430. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0438\u043c\u0435\u043d\u043d\u043e \u0432\u0430\u0448\u0435\u0433\u043e! \u041e\u0431\u0440\u0430\u0449\u0430\u0439\u0442\u0435\u0441\u044c \u043a \u043d\u0430\u043c \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043f\u043e\u0434 \u043a\u043b\u044e\u0447. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043d\u0430 \u043f\u043e\u0434\u0440\u044f\u0434\u0435, \u0441\u0443\u0431\u043f\u043e\u0434\u0440\u044f\u0434\u0435, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u0443\u0442\u0441\u0442\u0430\u0444\u0444.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/831696\/\"> https:\/\/habr.com\/ru\/articles\/831696\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<h2>\u041d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f \u043f\u043e \u0446\u0438\u043a\u043b\u0443 \u0441\u0442\u0430\u0442\u0435\u0439:<\/h2>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/830120\/\" rel=\"noopener noreferrer nofollow\">\u0427\u0430\u0441\u0442\u044c 1. \u041f\u0438\u0448\u0435\u043c \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043a\u043b\u0438\u043a\u0435\u0440 \u043d\u0430 Kotlin<\/a><br \/>\u0427\u0430\u0441\u0442\u044c 2. \u041f\u0438\u0448\u0435\u043c \u043a\u043b\u0438\u043a\u0435\u0440 \u0434\u043b\u044f Telegram \u043d\u0430 Kotlin \u2013 \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f<br \/>\u0427\u0430\u0441\u0442\u044c 2 \u0441 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u043e\u0439. \u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 rest-framework. TMA \u043d\u0430 KMP \u2013 \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435<br \/>\u0427\u0430\u0441\u0442\u044c 3. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u043f\u043b\u0430\u0442\u0443 \u0447\u0435\u0440\u0435\u0437 Telegram Mini Apps \u043d\u0430 Kotlin \u2013 \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435<\/p>\n<h2>\u0420\u0430\u0441\u043a\u0440\u044b\u0442\u044b\u0435 \u0442\u0435\u043c\u044b \u0432 \u0446\u0438\u043a\u043b\u0435<\/h2>\n<ul>\n<li>\n<p>Web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 Kotlin \u2013 \u0447\u0430\u0441\u0442\u044c 1<\/p>\n<\/li>\n<li>\n<p>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 Telegram Mini Apps \u2013 \u0447\u0430\u0441\u0442\u044c 2<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 TMA \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0422\u0435\u043c\u0430,\u00a0<code>MainButton<\/code>,\u00a0<code>BackButton<\/code>\u00a0\u2013 \u0447\u0430\u0441\u0442\u044c 2<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 Telegram. \u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 \u0441\u0441\u044b\u043b\u043a\u0443 \u2013 \u0447\u0430\u0441\u0442\u044c 2<\/p>\n<\/li>\n<li>\n<p>\u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 TMA \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u2013 \u0447\u0430\u0441\u0442\u044c 2 \u0438 2.5<\/p>\n<\/li>\n<li>\n<p>Telegram Payments API\u2013 \u0447\u0430\u0441\u0442\u044c 3<\/p>\n<\/li>\n<\/ul>\n<h2>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 Telegram<\/h2>\n<p>Telegram Mini Apps (\u0434\u0430\u043b\u0435\u0435 &#8212; TMA), \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e, \u0442\u043e \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a API, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0439 Telegram. \u0418\u0437 \u0447\u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0441\u0442\u0435\u043a, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439 \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0435 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 Telegram<\/p>\n<p>\u0414\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 Telegram \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0431\u043e\u0442\u0430 \u0447\u0435\u0440\u0435\u0437 BotFather \u043f\u043e\u00a0<a href=\"https:\/\/core.telegram.org\/bots#how-do-i-create-a-bot\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>. \u0421\u0430\u043c \u0442\u043e\u043a\u0435\u043d \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f, \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0431\u043e\u0442\u0430 \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0412 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u0431\u043e\u0442\u0430 (\u0432 \u0447\u0430\u0442\u0435 \u0441 BotFather) \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043c\u0435\u043d\u044e\u00a0<code>Bot Settings<\/code>\u00a0&gt;&gt;\u00a0<code>Menu Button<\/code>\u00a0&gt;&gt;\u00a0<code>Customize menu button<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0441 \u043f\u0440\u043e\u0441\u044f\u0442 \u0432\u0432\u0435\u0441\u0442\u0438 \u0441\u0441\u044b\u043b\u043a\u0443, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0448 \u0431\u043e\u0442.<\/p>\n<blockquote>\n<p><code>localhost<\/code>\u00a0\u043d\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0443 \u0432\u0430\u0441 \u043e\u043d \u043d\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 \u043f\u0440\u0438\u0451\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e https. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0434\u0451\u043c \u043f\u043e \u0441\u0430\u043c\u043e\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u043e\u043c\u0443 \u043f\u0443\u0442\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u00a0<code>ngrok<\/code>. \u0414\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u0441\u0430\u0439\u0442\u0435\u00a0<a href=\"https:\/\/ngrok.com\/\" rel=\"noopener noreferrer nofollow\">ngrok<\/a>, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0435\u0433\u043e \u0438 \u043f\u0440\u043e\u0439\u0434\u0438\u0442\u0435 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443. \u0421\u0430\u043c \u0437\u0430\u043f\u0443\u0441\u043a, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u0442\u0430\u043f, \u043f\u0440\u043e\u0441\u0442:<\/p>\n<\/blockquote>\n<pre><code class=\"bash\">ngrok http http:\/\/localhost:8080 --host-header=\"localhost:8080\"<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0445\u043e\u0441\u0442, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0441 https \u0441\u0445\u0435\u043c\u043e\u0439<\/p>\n<figure class=\"\"><\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u0432 BotFather \u0438 \u0437\u0430\u0434\u0430\u0451\u043c \u043d\u0430\u0434\u043f\u0438\u0441\u044c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0435. \u0413\u043e\u0442\u043e\u0432\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0432\u0435\u0436\u0435\u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0431\u043e\u0442\u0430 \u0435\u0441\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0430. \u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0448\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<h2>\u041d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c TMA (MainButton, BackButton)<\/h2>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u044d\u043a\u0440\u0430\u043d, \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c enum, state \u0438 when.<\/p>\n<pre><code class=\"kotlin\">\/\/ Don't use in real code enum class Screen {     CLICKER,     FRIENDS_LIST, }  \/\/ Don't use in real code var currentScreen by mutableStateOf(Screen.CLICKER)  @Composable fun App() {     when (currentScreen) {         Screen.CLICKER -&gt; ClickerScreen(             onFriendsList = {                 currentScreen = Screen.FRIENDS_LIST             }         )          Screen.FRIENDS_LIST -&gt; FriendsListScreen(             onBack = {                 currentScreen = Screen.CLICKER             },         )     } }<\/code><\/pre>\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u043d\u0435\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u043b\u0441\u044f \u0432\u00a0<code>App()<\/code>\u0432\u044b\u043d\u043e\u0441\u0438\u043c \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u044d\u043a\u0440\u0430\u043d \u0441 callback \u043d\u0430 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u044d\u043a\u0440\u0430\u043d<\/p>\n<pre><code class=\"kotlin\">val score = mutableStateOf(0L)  @Composable fun ClickerScreen(     onFriendsList: () -&gt; Unit, ) {     Div(         attrs = {             classes(ClickerStyles.MainContainer)         }     ) {         Div(             attrs = {                 classes(ClickerStyles.ClickerBlock)             }         ) {             H2 {                 Text(\"Score: ${score.value}\")             }             Img(                 src = Res.images.click_item.fileUrl,                 attrs = {                     classes(ClickerStyles.MainImage)                     onClick {                         score.value += 1                     }                 }             )         }     } }<\/code><\/pre>\n<p>\u0412\u0442\u043e\u0440\u044b\u043c \u044d\u043a\u0440\u0430\u043d\u043e\u043c \u0441\u0442\u0430\u043d\u0435\u0442 \u0441\u0430\u043c\u0430\u044f \u0432\u0430\u0436\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u043a\u043b\u0438\u043a\u0435\u0440\u043e\u0432 \u2013 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0440\u0443\u0437\u0435\u0439. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0442\u044c \u0438\u0445 \u0432 \u043d\u0430\u0448\u0443 \u0438\u0433\u0440\u0443 \u0447\u0435\u0440\u0435\u0437 \u0441\u0441\u044b\u043b\u043a\u0443.<\/p>\n<pre><code class=\"kotlin\">@Composable fun FriendsListScreen(     onBack: () -&gt; Unit, ) {     Div(         attrs = {             classes(FriendsListStyle.Container)         }     ) {         H4 {             Text(\"\u0423 \u0442\u0435\u0431\u044f \u043f\u043e\u043a\u0430 \u043d\u0435\u0442 \u0434\u0440\u0443\u0437\u0435\u0439...\")         }     }  }<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u044d\u043a\u0440\u0430\u043d\u044b, \u043d\u043e \u043f\u043e \u043d\u0438\u043c \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 Telegram: \u044d\u0442\u043e\u00a0<code>MainButton<\/code>\u00a0\u0438\u00a0<code>BackButton<\/code>.<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0430\u043c TMA API \u0432 \u043d\u0430\u0448\u0435 \u0432\u0435\u0431 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0435\u0439, \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u043e\u0439 \u043e\u0431\u0451\u0440\u0442\u043a\u043e\u0439 \u043d\u0430\u0434 JS \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 TMA<\/p>\n<pre><code class=\"kotlin\">jsMain.dependencies {     \/\/\u2026     implementation(\"dev.inmo:tgbotapi.webapps:15.0.0\") }<\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u044d\u0442\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0432\u0440\u0430\u043f\u0435\u0440\u043e\u043c \u0434\u043b\u044f API \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c, \u0432 \u043d\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c js \u0432\u0435\u0440\u0441\u0438\u044e TMA API. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0451 \u043a\u0430\u043a\u00a0<code>script<\/code>\u00a0\u0432\u00a0<code>index.html<\/code>\u00a0\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435.<\/p>\n<pre><code class=\"xml\">&lt;head&gt;     ...     &lt;script src=\"https:\/\/telegram.org\/js\/telegram-web-app.js\"&gt;&lt;\/script&gt; &lt;\/head&gt;<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u00a0<code>webApp<\/code>,\u00a0\u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u044f\u00a0<code>backButton<\/code>\u00a0\u0438\u00a0<code>mainButton<\/code>.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u043e\u044f\u0432\u0438\u043c \u0441\u043c\u0435\u043a\u0430\u043b\u043a\u0443 \u0438 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u0443\u0435\u043c \u0438\u0445 \u043f\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437 composable \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u2013 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0438\u0437 \u043d\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b.<\/p>\n<pre><code class=\"kotlin\">@Composable fun WebAppMainButton(     text: String,     onClick: () -&gt; Unit,     visible: Boolean = true,     active: Boolean? = undefined,     loading: Boolean = false,     loadingLeaveActive: Boolean = false,     hideOnDispose: Boolean = true, \/\/ use if next screen has MainButton too     color: String? = undefined,     textColor: String? = undefined, ) {     DisposableEffect(visible) {         if (visible) {             webApp.mainButton.show()         } else {             webApp.mainButton.hide()         }         onDispose {             if (hideOnDispose)                 webApp.mainButton.hide()         }     }     DisposableEffect(         keys = arrayOf(             onClick, text, color, textColor, visible, active,             loading, loadingLeaveActive         ),     ) {         webApp.mainButton.onClick(onClick)         webApp.mainButton.setParams(             MainButtonParams(                 text = text,                 color = color,                 textColor = textColor,                 isActive = active,                 isVisible = visible,             )         )         if (loading)             webApp.mainButton.showProgress(leaveActive = loadingLeaveActive)         else             webApp.mainButton.hideProgress()         onDispose {             webApp.mainButton.offClick(onClick)         }     } }  @Composable fun WebAppBackButton(     onClick: () -&gt; Unit, ) {     DisposableEffect(Unit) {         webApp.backButton.onClick(onClick)         webApp.backButton.show()         onDispose {             webApp.backButton.hide()             webApp.backButton.offClick(onClick)         }     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0449\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 TMA API. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u043a\u043d\u043e\u043f\u043a\u0443 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0440\u0443\u0437\u0435\u0439 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u043a\u043b\u0438\u043a\u0435\u0440\u0430, \u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u0440\u0443\u0437\u0435\u0439 \u043a\u043d\u043e\u043f\u043a\u0443 \u043d\u0430\u0437\u0430\u0434.<\/p>\n<pre><code class=\"kotlin\">@Composable fun FriendsListScreen(     onBack: () -&gt; Unit, ) {     WebAppBackButton(onClick = onBack)     \/\/ ... }  @Composable fun ClickerScreen(     onFriendsList: () -&gt; Unit, ) {     WebAppMainButton(         text = \"\u0421\u043f\u0438\u0441\u043e\u043a \u0434\u0440\u0443\u0437\u0435\u0439\",         hideOnDispose = false,         onClick = onFriendsList     )     \/\/ ... }<\/code><\/pre>\n<figure class=\"full-width\">\n<div><figcaption><em>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0438\u043a\u043e\u043d\u043a\u043e\u0439 \u0434\u043b\u044f \u0442\u0430\u043f\u0430 \u0438 \u0437\u0430\u0441\u043a\u0440\u0438\u043d\u0438\u0442\u044c \u0437\u0430\u043d\u043e\u0432\u043e<\/em>  <\/figcaption><\/div>\n<\/figure>\n<h2>\u0422\u0435\u043c\u0430 \u043a\u0430\u043a \u0443 Telegram<\/h2>\n<p>\u0426\u0432\u0435\u0442\u0430 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u0438\u043b\u044c\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f, \u043d\u043e TMA API \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0432\u043e\u0438 \u0446\u0432\u0435\u0442\u0430 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u0445 \u0432 \u0441\u0432\u043e\u0451\u043c CSS. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0436\u0435 \u044d\u0442\u0438 \u0441\u0442\u0438\u043b\u0438 \u043a \u0441\u0435\u0431\u0435 \u0447\u0435\u0440\u0435\u0437 CSS in Kotlin. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c AppStyles, \u0433\u0434\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u044d\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f css variables<\/p>\n<pre><code class=\"kotlin\">object TMAVariables {     val BackgroundColorValue = Color(\"#ffffff\")     val BackgroundColor by variable&lt;CSSColorValue&gt;()     val SecondaryBackgroundColorValue = Color(\"#ffffff\")     val SecondaryBackgroundColor by variable&lt;CSSColorValue&gt;()     val TextColorValue = Color(\"#000000\")     val TextColor by variable&lt;CSSColorValue&gt;()     val HintColorValue = Color.gray     val HintColor by variable&lt;CSSColorValue&gt;()     \/\/ \u0418 \u0442. \u0434., \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 github }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u00a0<code>ThemeParams<\/code>, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0433\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0434\u043b\u044f\u00a0<code>StyleScope<\/code>. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e\u043b\u044f \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c null, \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 variable.<\/p>\n<pre><code class=\"kotlin\">fun StyleScope.applyThemeVariables(theme: ThemeParams) {     BackgroundColor(theme.backgroundColor?.toCSSColorValue() ?: BackgroundColorValue)     SecondaryBackgroundColor(theme.secondaryBackgroundColor?.toCSSColorValue() ?: SecondaryBackgroundColorValue)     TextColor(theme.textColor?.toCSSColorValue() ?: TextColorValue)     HintColor(theme.hintColor?.toCSSColorValue() ?: HintColorValue)     \/\/ \u0418 \u0442. \u0434., \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 github }<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u0443\u044e, \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441\u0442\u0438\u043b\u0435\u0439, \u0433\u0434\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 CSS variables \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0442\u0435\u0433\u043e\u0432.<\/p>\n<pre><code class=\"kotlin\">class AppStyles(val themeParams: ThemeParams) : StyleSheet() {     init {         \"body\" style {             applyThemeVariables(themeParams)             backgroundColor(TMAVariables.BackgroundColor.value())             color(TMAVariables.TextColor.value())         }         \"a\" style {             color(TMAVariables.LinkColor.value())         }         \"button\" style {             color(TMAVariables.ButtonTextColor.value())             backgroundColor(TMAVariables.ButtonColor.value())         }     } }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u0442\u0438\u043b\u044c \u0432\u00a0<code>renderComposable<\/code>, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0442\u0435\u043c\u044b\u00a0<code>webApp.themeParams<\/code><\/p>\n<pre><code class=\"kotlin\">renderComposable(rootElementId = \"app\") {     Style(AppStyles(webApp.themeParams))     \/\/ ... }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0438 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0446\u0432\u0435\u0442\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0447\u0435\u0442\u0430\u044e\u0442\u0441\u044f \u0441 Telegram<\/p>\n<figure class=\"\"><\/figure>\n<h2>\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>\u041a\u0440\u0430\u0442\u043a\u0430\u044f \u0441\u043f\u0440\u0430\u0432\u043a\u0430: \u043a\u0430\u0436\u0434\u044b\u0439 TMA \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0441 query params, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f id \u0438 \u043a\u0440\u0430\u0442\u043a\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041e\u043d\u0438 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043f\u043e\u043b\u044f\u0445\u00a0<code>webApp.initData<\/code>\u00a0\u0438\u00a0<code>webApp.initDataUnsafe<\/code>. \u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u2013 \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e initData \u2013 \u044d\u0442\u043e \u0441\u044b\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f\u00a0<a href=\"https:\/\/core.telegram.org\/bots\/webapps#validating-data-received-via-the-mini-app\" rel=\"noopener noreferrer nofollow\">\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438<\/a>,\u00a0<code>initDataUnsafe<\/code>\u00a0\u2013 \u044d\u0442\u043e type-safe \u043e\u0431\u044a\u0435\u043a\u0442, \u0433\u0434\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0443\u0436\u0435 \u0432 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435, \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0435 \u043d\u0438\u043a\u0430\u043a \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, username \u0438\u043b\u0438 id.<\/p>\n<figure class=\"\">\n<div><figcaption>image.png<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441\u00a0<code>webApp.initData<\/code>.\u00a0<code>TapClient<\/code>\u00a0\u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0432 commonMain \u0438 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c.<\/p>\n<pre><code class=\"kotlin\">object TapClient {     private val client: HttpClient = HttpClient(TapClientEngine) {         \/\/ \u2026         authConfig()     }<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-427484","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/427484","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=427484"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/427484\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=427484"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=427484"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=427484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}