Inside of my Telegram Mini App, say I have an anchor tag <a href="google.com">External URL</a>
, which then opens inside of the telegram app itself. As is, there is no way to navigate back to the original app, except clicking the ‘Close’ button in the top left and then opening the TMA again from the bot main button.
I can enable the ‘Back’ button with window.Telegram.WebApp.BackButton.show();
, which visually changes the ‘Close’ button to a ‘< Back’ button but which does nothing on click. I’ve tried to bind it to navigate back like so:
window.Telegram.WebApp.BackButton.onClick(() => {
alert("Navigated back!");
history.back();
});
While the alert fires when inside the original app, once the user clicks into the external link, the back button no longer works (and the alert no longer fires). As such I can guess that the function is only bound to the button when in the original app, which is not helpful to me as I’m trying to allow the user to navigate back to the app after viewing an external file. How can I permanently bind the function to the back button or, failing that, achieve some way to allow the users to navigate back to the original app after viewing an external file?