I found that the method Expand of window.Telegram.WebApp object isn’t working in the Telegram client for Windows and IOS on computers and tablets.
How to increase the size of Web Apps frame for those devices?
Question posted in Telegram API
A comprehensive official documentation can be found here.
A comprehensive official documentation can be found here.
3
Answers
Other button events
Remove the line from the function:
And call it in the beginning/at the top of your main javascript code. (The code that will start running once the user has clicked on the button)
Also, you can make your code a lot shorter by putting
window.Telegram.WebApp
in a variable like:The reason is, probably, you are a bit incorrect in understanding what "expansion" is. This term could only be applied to mobile devices with OS such as Android or iOS. Web App is displayed there in such native component as BottomSheet with inserted WebView containing your web application. Initially, in mobile devices, application is being opened minimized (not expanded). To make it use maximum allowed height of screen, you could call
expand()
method. It must work throughwindow.Telegram.WebApp.expand()
.In desktop or web versions of Telegram, Web App is displayed in separate component which is not allowed to change its size.
You could probably find more useful information about viewport and expansion here, or use alternative libraries, such as
twa-bridge
ortwa-sdk