mirror of
https://github.com/MarshalX/telegram-crawler.git
synced 2024-11-28 19:23:11 +01:00
Update content of files
This commit is contained in:
parent
0304be8826
commit
a013fbe4cd
1 changed files with 10 additions and 12 deletions
|
@ -42,21 +42,18 @@
|
|||
<div id="dev_page_content"><!-- scroll_nav -->
|
||||
|
||||
<p>When interacting with HTML5 games and the websites of payment gateways, Telegram apps should expose APIs to allow receiving data and events from the websites.</p>
|
||||
<h3><a class="anchor" href="#event-apis" id="event-apis" name="event-apis"><i class="anchor-icon"></i></a>Event APIs</h3>
|
||||
<p>Games and payment gateways can generate events that are meant to be received by the Telegram apps.
|
||||
Typically events are generated by using the <code>postEvent</code> method of the <a href="https://github.com/TelegramMessenger/GamingCommunication/blob/master/games.js">GamingCommunication library</a>.
|
||||
The <code>postEvent</code> function will try sending the event to the Telegram app in a number of different ways.</p>
|
||||
<h4><a class="anchor" href="#webviewproxy" id="webviewproxy" name="webviewproxy"><i class="anchor-icon"></i></a>WebviewProxy</h4>
|
||||
<h3><a class="anchor" name="event-apis" href="#event-apis"><i class="anchor-icon"></i></a>Event APIs</h3>
|
||||
<p>Games and payment gateways can generate events that are meant to be received by the Telegram apps.<br>Typically events are generated by using the <code>postEvent</code> method of the <a href="https://github.com/TelegramMessenger/GamingCommunication/blob/master/games.js">GamingCommunication library</a>.<br>The <code>postEvent</code> function will try sending the event to the Telegram app in a number of different ways.</p>
|
||||
<h4><a class="anchor" name="webviewproxy" href="#webviewproxy"><i class="anchor-icon"></i></a>WebviewProxy</h4>
|
||||
<p>In mobile apps, the event receiver API should be typically exposed as a <code>window.TelegramWebviewProxy</code> object with a <code>postEvent</code> method.</p>
|
||||
<pre><code>window.TelegramWebviewProxy.postEvent(eventType, eventData)</code></pre>
|
||||
<h4><a class="anchor" href="#windowexternal" id="windowexternal" name="windowexternal"><i class="anchor-icon"></i></a>window.external</h4>
|
||||
<h4><a class="anchor" name="window-external" href="#window-external"><i class="anchor-icon"></i></a>window.external</h4>
|
||||
<p>Alternatively, a <code>window.external.notify</code> method can be exposed, accepting a string JSON payload with the event type and payload:</p>
|
||||
<pre><code>window.external.notify(JSON.stringify({eventType: eventType, eventData: eventData}));</code></pre>
|
||||
<h4><a class="anchor" href="#postmessage-api" id="postmessage-api" name="postmessage-api"><i class="anchor-icon"></i></a>postMessage API</h4>
|
||||
<p>Finally, web MTProto clients that need to open a game or process a payment in an iframe can use the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage">postMessage API</a> to receive events from iframes.
|
||||
The <a href="https://github.com/TelegramMessenger/GamingCommunication/blob/master/games.js">GamingCommunication library</a> by defaultwill use <code>'*'</code> as <code>targetOrigin</code>, sending messages to parent pages regardless of the origin of the embedder.</p>
|
||||
<h4><a class="anchor" name="postmessage-api" href="#postmessage-api"><i class="anchor-icon"></i></a>postMessage API</h4>
|
||||
<p>Finally, web MTProto clients that need to open a game or process a payment in an iframe can use the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage">postMessage API</a> to receive events from iframes.<br>The <a href="https://github.com/TelegramMessenger/GamingCommunication/blob/master/games.js">GamingCommunication library</a> by default will use <code>'*'</code> as <code>targetOrigin</code>, sending messages to parent pages regardless of the origin of the embedder.</p>
|
||||
<pre><code>window.parent.postMessage(JSON.stringify({eventType: eventType, eventData: eventData}), targetOrigin);</code></pre>
|
||||
<h4><a class="anchor" href="#event-types" id="event-types" name="event-types"><i class="anchor-icon"></i></a>Event types</h4>
|
||||
<h4><a class="anchor" name="event-types" href="#event-types"><i class="anchor-icon"></i></a>Event types</h4>
|
||||
<p><code>eventType</code> is a simple string indicating the event type, and <code>eventData</code> is a payload with an object that will be parsed by the Telegram app.</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
|
@ -80,7 +77,7 @@ The <a href="https://github.com/TelegramMessenger/GamingCommunication/blob/maste
|
|||
<tr>
|
||||
<td><code>share_game</code></td>
|
||||
<td>null</td>
|
||||
<td>Will be called by games when the user explicitly clicks on the <strong>share game</strong> button to share the game, without sharing his score.<br>Typically done by using <a href="/method/messages.forwardMessages">messages.forwardMessages</a> on the game message without the <code>with_my_score</code> flag, or by sharing the game's short URL.</td>
|
||||
<td>Will be called by games when the user explicitly clicks on the <strong>share game</strong> button to share the game, without sharing his score.<br>Typically done by using <a href="/method/messages.forwardMessages">messages.forwardMessages</a> on the game message without the <code>with_my_score</code> flag, or by sharing the game's short URL.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>game_over</code></td>
|
||||
|
@ -98,7 +95,8 @@ The <a href="https://github.com/TelegramMessenger/GamingCommunication/blob/maste
|
|||
<td>Called by supported pages inside of <a href="https://instantview.telegram.org">IV</a> iframe embeds, indicates the new size of the embed frame.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue