Reputation: 31
I am building Telegram Web App (Mini App). I initiated Telegram Web App using the official script published on their website: https://core.telegram.org/bots/webapps#initializing-mini-apps
I successfully initiated the app, but when I am trying to use the latest features, like write and read from cloud storage or render the native pop up, I get exception "Method is not supported in version 6.0". The problem is, that version 6.0 is only version I could get and it is defined in the script to initialize Telegram Web App.
Has anyone encountered the same problem? Am I missing something or it's just Telegram published outdated version on their resource?
I tried to read the API documentation more precisely and tried to find a method to set the version. I contacted the telegram support but they didn't even bother to give me feedback.
Upvotes: 3
Views: 3893
Reputation: 21
According to the documentation (https://docs.telegram-mini-apps.com/packages/telegram-apps-sdk/3-x/initializing) @telegram-apps/sdk
can be installed as a package, in which case there is no need to use the external script telegram-web-app.js
. Or try this package: https://www.npmjs.com/package/@twa-dev/sdk
Upvotes: 0
Reputation: 1
What new feature are you looking to use? Some features can only be called at the top level when the HTML loads, and it's best to ensure that the SDK script is loaded at the very top of the head tag.
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://telegram.org/js/telegram-web-app.js"></script>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ton Sample TWA</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Bungee&display=swap" rel="stylesheet">
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script>eruda.init();</script>
<script type="text/javascript">
(function () {
const tele = window.Telegram.WebApp;
tele.ready()
tele.expand();
tele.BackButton.show();
tele.SettingsButton.show();
tele.setHeaderColor("#fcf6e2")
tele.setBackgroundColor("#fcf6e2")
tele.enableClosingConfirmation()
tele.disableVerticalSwipes()
})()
</script>
</body>
</html>
Upvotes: 0
Reputation: 13
i faced the same. my remedy is: to store the file telegram-web-app.js on my server, where to change the parameter
var webAppVersion = '7.7';
works good.
Upvotes: 0
Reputation: 129
I was facing the same issue, and then I took a deep dive into the telegram-web-app.js
file, and I noticed it has a hardcoded version of 6.0, which is then updated using the tgWebVersion
param of the window.Telegram.WebView.initParams
This value is empty if you don't view the webpage from a telegram client, else the values are inferred.. I didn't look at how these values are loaded tho.
Upvotes: 2