postMessage bridge

The mini-app and the host talk through window.postMessage with plain JSON objects. Every message has a channel of truevision-app and a type. This page lists every message in both directions.

How messages reach you

The mini-app calls window.parent.postMessage(message, "*"). In an iframe that is your page's window. In a native WebView the mini-app is the top frame, so window.parentis the mini-app's own window and the event fires there. Your app therefore has to inject a listener into the page that forwards bridge messages to native code, ideally at document start so the first message (ready) is not missed. Install in your app has the Android and iOS snippets.

Listener glue injected into the pageJavaScript
window.addEventListener("message", (e) => {
  if (!e.data || e.data.channel !== "truevision-app") return;
  // Android: truevisionHost.postMessage(JSON.stringify(e.data))
  // iOS:     window.webkit.messageHandlers.truevision.postMessage(e.data)
});

To send a command, evaluate JavaScript in the WebView (or frame.contentWindow.postMessage in an iframe):

JavaScript
window.postMessage({ channel: "truevision-app", type: "pause" }, "*");

Messages from the mini-app to the host

typeFieldsWhen
ready—The page has mounted. Hide your loading state.
auth-statestate: "signed-in" | "signed-out"On every page load, after the token bootstrap, and again (signed-out) when the token expires.
sign-inid, returnUrlThe player's token was rejected and the viewer tapped Sign In. Re-run the landing POST with your token, then reopen returnUrl. See Authentication.
open-contentid, contentType: "livetv" | "movie", channelCode?, episodeId?, lang, nowUrlThe viewer tapped a card, Watch Now or an episode row. In playback mode app this is a notification; in mode host it is a request to play. See Player.
close—The viewer tapped X on a detail page or the player. Dismiss the WebView or pop your navigation.
orientationorientation: "landscape" | "portrait"The player opens (landscape) and closes (portrait). Rotate or lock the WebView. Browse pages never send it.
playback-statestate: "playing" | "paused" | "buffering" | "ended"The built-in player changed state.
playback-errorcode, messageThe player could not load or play the source (Bitmovin error code and name).
subscribeid, nowUrl, purchaseUrl, openedThe viewer tapped Subscribe Now or Manage Access. purchaseUrl is the TrueVisions offer page on account.truevisions.co.th (Sports 499 for sport, ENT 99 for series and movies). opened is true when the mini-app already opened it, signed in: in the same WebView, or in a new window when the mini-app runs in an iframe.
open-appid, nowUrlThe title only plays in the TrueVisions NOW app. Deep-link into it.
ExamplesJSON
{ "channel": "truevision-app", "type": "ready" }

{ "channel": "truevision-app", "type": "open-content",
  "id": "7f3e…", "contentType": "movie", "episodeId": "ep-12", "lang": "th",
  "nowUrl": "https://now.truevisions.co.th/th/content/7f3e…" }

{ "channel": "truevision-app", "type": "open-content",
  "id": "ch-1", "contentType": "livetv", "channelCode": "TS1", "lang": "en",
  "nowUrl": "https://now.truevisions.co.th/en/content/ch-1" }

{ "channel": "truevision-app", "type": "orientation", "orientation": "landscape" }
{ "channel": "truevision-app", "type": "playback-state", "state": "buffering" }
{ "channel": "truevision-app", "type": "playback-error", "code": 1400, "message": "SOURCE_ERROR" }
{ "channel": "truevision-app", "type": "subscribe", "id": "7f3e…",
  "nowUrl": "https://now.truevisions.co.th/th/content/7f3e…",
  "purchaseUrl": "https://account.truevisions.co.th/th/package/NOWTM_0_1/offer/NOW_TM_99_1?utm_source=internal_truemoveh_app-banner&utm_medium=app-banner&utm_campaign=app_miniapp_2026", "opened": false }
{ "channel": "truevision-app", "type": "close" }

Messages from the host to the mini-app

typeFieldsEffect
playchannelId?: stringResume the built-in player. With channelId, only the player showing that content reacts.
pause—Pause the built-in player.
JSON
{ "channel": "truevision-app", "type": "pause" }
{ "channel": "truevision-app", "type": "play", "channelId": "ch-1" }

Pause the player when your app goes to the background or a phone call interrupts; resume with play when it returns.

Recommended handling

  • ready: hide the spinner. If it never arrives within a few seconds, show a retry.
  • orientation: request landscape and hide the system bars for the player; restore portrait afterwards. Code for Android and iOS is in Install. If you do not rotate, the player turns itself inside the WebView.
  • close: pop the WebView screen. The mini-app has already sent orientation portrait.
  • subscribe: if opened is false, open purchaseUrl in a browser or in-app browser. If it is true, do nothing: the offer page is already open, in the same WebView (or in a new window from an iframe). Your WebView must allow navigation to account.truevisions.co.th.
  • open-app: deep-link into the TrueVisions NOW app. Use nowUrl in a browser as the fallback.
  • open-content in mode host: play id (and episodeId) in your native player; the mini-app does nothing else.
  • Unknown types: ignore them. New messages may be added without notice; existing ones will not change shape.