telegram-bot-api
telegram-bot-api copied to clipboard
[Bug] Url Schemes not working in WebApps
URLs with protocols different from http:/https: don't work in Bot API's WebApps, breaking the user experience when the webapp includes features that require to open different apps (like sharing, playing media, etc...).
It doesn't work in anchor's href, nor launched by a window.open(), nor Telegram.WebApp.openLink().
Minimal reproducible html example, that on a normal mobile browser opens the whatsapp app (if installed), but doesn't work on Telegram:
<a href="whatsapp://send?text=Hello%20World">
Open WhatsApp
</a>
The issue can be easily fixed by handling url scheme intents when the webview wants to load a URL (Android example: https://stackoverflow.com/a/53059413/14175236)
Web Apps exist to simplify interaction of Telegram bots with users, so these links aren't supposed to work in Web Apps.
Web Apps exist to simplify interaction of Telegram bots with users, so these links aren't supposed to work in Web Apps.
That's exactly what they lack to do if url schemes are not supposed to work in Web Apps.
I could list you dozens of basic use cases that wouldn't work, ruining the experience of Telegram users and the interest of developers in developing Web App bots:
- authetication through a different app (to sync the leaderboard of a game? to finalize or approve a restaurant/hotel order?)
- free/new-apps discovery bot, that's supposed to let the user open these apps on their device store (e.g.: using
market://details?id=<package-name> - bot or score sharing on social medias (this one not only is a very very basic use-case, but it also limits the potential reach of Telegram among the outside non-telegram-users world).
- showing media that can be played on their native apps (e.g.: YouTube videos, TikTok, etc)
- any side-feature part of a developer's app, that doesn't make sense/it's not possible to redevelop, in case of bots that work as interfaces to ease the interactions of users. It is better to keep on Telegram during the main flow and eventually let them interact with other apps when needed, rather than cutting the opportunity to have hybrid apps and not allowing users to use them through Telegram.
- etc etc...
I can't see a single valid reason for not supporting a native feature that works with every existing browser and every major app that makes use of a WebView.
Plus, if not documented, it's a bug. As a developer, I expect every common web feature to work inside of a Web App.
These links don't work inside Telegram either, so it is strange to expect them to work in a Web App.
Anyway, you can always use a redirect from your site to a URL with custom URL scheme.
Its a Bug, same problem on my project. Any fix variants?
@Clarxxon Just read above messages.
@levlam is any way to use "tel:{phoneNumber}" link in Telegram WebApp?
@VadimBirkos See https://github.com/tdlib/telegram-bot-api/issues/299#issuecomment-1192413247.
@levlam But if I want to connect something like WalletConnect or MetaMask, I get an error with wc://... url scheme and UNKNOWN_URL_SCHEME error. Can I something do with this?
You can always use a redirect from your site to a URL with custom URL scheme.
We're using universal links by appsflyer onelink redirects in order to force deeplink opening (Cause iOS can remember eventually to open links in safari only and this way you get stuck on website cause it's webview). But yeah would be awesome to have this inside Telegram.WebApp.openLink api. This way it'd be truly seamless.