Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
reveloper committed Oct 23, 2023
1 parent 2e54166 commit 465dbc9
Showing 1 changed file with 2 additions and 37 deletions.
39 changes: 2 additions & 37 deletions docs/develop/dapps/telegram-apps/tips-and-tricks.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Tips and Tricks

Expand Down Expand Up @@ -47,43 +45,10 @@ In many web applications, users might accidentally close the app while scrolling
</p>


To prevent such accidental closures, developers can use `closing_behavior` method in the TMA. This method will display a dialog where the user can either approve or decline the closing of the Web App.
To prevent such accidental closures, enable `closing_behavior` in the TMA. This method will add a dialog where the user can either approve or decline the closing of the Web App.



<Tabs groupId="code-examples">

<TabItem value="web" label="Web">

```typescript
window.parent.postMessage(JSON.stringify({
eventType: 'web_app_setup_closing_behavior',
eventData: {need_confirmation: true},
}), 'https://web.telegram.org');
```

</TabItem>

<TabItem value="desktop-and-mobile" label="Desktop&Mobile">

```typescript
window.TelegramWebviewProxy.postEvent('web_app_setup_closing_behavior', JSON.stringify({
need_confirmation: true
}));
window.Telegram.WebApp.enableClosingConfirmation()
```

</TabItem>


<TabItem value="w-phone" label="Windows Phone">

```typescript
window.external.notify(JSON.stringify({
eventType: 'web_app_setup_closing_behavior',
eventData: {need_confirmation: true},
}))

```

</TabItem>
</Tabs>

0 comments on commit 465dbc9

Please sign in to comment.