Skip to content
TruCom Developers
JavaScript SDK
DocumentationIntegrations
JAVASCRIPT SDK

Embed in mobile apps

Use a WebView, your own app button and a JSON command/event bridge.

Embedded presentation

Serve a small HTTPS support page that loads your widget in a container. Add that page’s host to Allowed domains. Use the same signed-identity flow as your website. This is a WebView integration, not a native Android/iOS messaging SDK or a native push SDK.

HTML / JavaScript
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<div id="support-root" style="height:100dvh"></div>
<script>
window.TruComWidgetConfig = {
  displayMode: 'embedded', container: '#support-root',
  mobileMode: true, nativeBridge: true, hideLauncher: true
};
</script>
<!-- Paste the full installation snippet from Settings here. -->

Native commands

Call receiveNativeCommand after the WebView SDK is ready. Pass JSON data, never construct JavaScript by interpolating unescaped customer values. Each command needs a string id, a supported method and an args array.

JavaScript
await TruComWidget.receiveNativeCommand({
  id: 'identify-1', method: 'identify',
  args: [{ identity_token: tokenFromYourBackend }]
});
await TruComWidget.receiveNativeCommand({ id: 'open-1', method: 'open', args: [] });

Results and events

Bridge envelopes have source:trucom-widget and version:1. Results include type:result, id and result or error. Events include type:event, event and data. No session token is exported. Prefer structured JSON objects; if injecting a command string, JSON.stringify both the command and its string argument.

JavaScript
// React Native WebView: onMessage receives event.nativeEvent.data.
// Flutter / Android / iOS: evaluate this safely constructed JavaScript.
const command = { id: 'close-1', method: 'close', args: [] };
const script = 'window.TruComWidget.receiveNativeCommand(' +
  JSON.stringify(JSON.stringify(command)) + ')';

Bridge adapters

OptionBehavior
React NativeThe SDK calls window.ReactNativeWebView.postMessage(JSON.stringify(envelope)). Set onMessage on your WebView.
iOS WKWebViewRegister the trucom script message handler. The SDK calls window.webkit.messageHandlers.trucom.postMessage(envelope). Restrict navigation to your support host.
Android WebViewExpose a narrow TruComAndroid.postMessage(String) interface only on your trusted support page. Keep JavaScript interfaces off unrelated navigation.
FlutterUse the Android interface name TruComAndroid or the iOS trucom message handler for the platform bridge; deserialize envelopes and correlate result IDs.
TruCom DevelopersSupport that belongs in your product.

Search documentation