Upotus
Lisää chat iframe-upotuksella verkkosivulle tai sovellukseen.
Iframe-upotus
Polku /embed?room=ingest:kanava. Teema: theme=vv, värit accent, bg, bgElevated.
<iframe
id="vv-live-chat"
src="https://chat.viihdevision.fi/embed?room=ingest:oma-kanava&theme=vv"
style="width:100%;height:480px;border:0;border-radius:12px"
allow="clipboard-write"
></iframe>
Hiljainen kirjautuminen
Upotus lähettää hostille ready-viestin. Host vastaa accessTokenilla. React Native WebView: sama JSON window.ReactNativeWebView.postMessage kautta.
window.addEventListener("message", (event) => {
const data = typeof event.data === "string" ? JSON.parse(event.data) : event.data
if (data?.source === "vv-live-chat" && data?.type === "ready") {
const iframe = document.getElementById("vv-live-chat")
iframe?.contentWindow?.postMessage(
{
source: "vv-live-chat-host",
type: "auth",
accessToken: "JM_ACCESS_TOKEN",
},
"*"
)
}
})Paikallinen kehitys: ?accessToken=... toimii, mutta on turvaton — älä käytä tuotannossa.