Is your feature request related to a problem? Please describe.
I'm trying to call navigator.sendBeacon when the app is closed or hidden. Listening to the visibilitychange and pagehide events works well to detect app hiding but these events are not fired when closing the mini app with the top-left close button (cross icon on Android).
Describe the solution you'd like
One of the following would be great:
Fire the document visibilitychange event before app is closed with the top-left close button, or
expose a callback like Telegram.WebApp.CloseButton.onClick that is called on close button click.
This works by replacing the close button with a back button. However, now when I want to minimize the mini app by swiping left, the app closes instead of minimizing.
Is your feature request related to a problem? Please describe.
I'm trying to call
navigator.sendBeacon
when the app is closed or hidden. Listening to thevisibilitychange
andpagehide
events works well to detect app hiding but these events are not fired when closing the mini app with the top-left close button (cross icon on Android).Describe the solution you'd like
One of the following would be great:
visibilitychange
event before app is closed with the top-left close button, orTelegram.WebApp.CloseButton.onClick
that is called on close button click.Describe alternatives you've considered
I tried hijacking the back button as follows:
This works by replacing the close button with a back button. However, now when I want to minimize the mini app by swiping left, the app closes instead of minimizing.
Additional context
Tested with the Android Telegram app.