LiSA Social Commerce
Developers
Developers
  • Developers
  • Guides
    • Integration Guide
      • Web Integration
      • App Integration
        • Android
          • Communication
          • Storage
          • File Downloads
          • Theming
        • iOS
          • Communication
          • Storage
          • File Downloads
          • Theming
        • React Native
          • Communication
          • Storage
          • File Downloads
          • Theming
        • Picture in Picture
      • Entrypoints
        • Query Parameter (v1)
    • Player Communication
      • Message API Reference
        • App
          • App — Heartbeat
          • App — Message Acknowledge
          • App — Message Error
          • App — Listen
        • CTA
          • CTA — Link in Comments
          • CTA — Sponsor Badge
        • Cart — View Cart
        • Comments — Join
        • Media
          • Media — Complete
          • Media — Pause
          • Media — Progress
          • Media — Resume
        • Media Item
          • Media Item — Emoji
          • Media Item — Impression
        • Player
          • Player — Dismiss
          • Player — Native Picture-in-Picture (PiP)
          • Player — Pass Visual Viewport
          • Player — Request Visual Viewport
          • Player — UI Transition
        • Products
          • Products — Add to Cart
          • Products — Add to Wishlist
          • Products — Click
          • Products — Close Product List
          • Products — Emoji
          • Products — Emoji State Update
          • Products — Impression
          • Products — Open Product List
        • Stickers
          • Stickers — Activate
          • Stickers — Click
          • Stickers — Expire
          • Stickers — Impression
          • Stickers — Publish
          • Stickers — Unlock
          • Stickers — Unpublish
          • Stickers — Update
          • Stickers — Voucher Claim
        • Visitor — Pass User Context
        • Shared Legacy Message Properties
    • Products
      • Product Update Notification API
  • Widgets
    • Content Hub
    • Quick Start Guide
    • Appearance
      • Markup
      • Responsive design
    • Configuration options
      • Autoplay
      • Channel
      • Client
      • Data
      • Debug
      • Host node
      • Layout
      • Language
      • On
      • Player
      • Query string
      • Quick view
      • Sections
      • Store
      • Template
    • API reference
      • Library API reference
      • Player API reference
      • Quick View API reference
    • Customisations
      • Template
      • Bring your own template
      • Type definitions
    • Examples
    • Type definitions
      • Asset
      • Product
      • Other
    • Promo Widget
      • Quick Start Guide
      • Configuration options
        • Autoplay
        • Channel
        • Countdown (deprecated)
        • Enabled
        • Image modifier
        • Lead time
        • Live (deprecated)
        • Position
        • Replay (deprecated)
        • Show ID
        • URL
  • Media Player Introduction
    • Picture-in-Picture Mode
  • Analytics
  • REST API
    • Authentication
    • Rate limits
    • Response status and error codes
    • API Documentation
Powered by GitBook
On this page
  • Receiving Messages
  • Sending Messages
  1. Guides
  2. Integration Guide
  3. App Integration
  4. React Native

Communication

This guide explains how to establish seamless bidirectional communication between your React Native app and the LiSA Player running within a WebView. By leveraging native-to-JavaScript bridges and WebView event listeners, you can enable your Android app and the LiSA Player to exchange data, trigger events, and synchronize state in real time.

Whether you need to send commands from you app to the LiSA Player (e.g., changing app behavior or updating content) or pass data from the WebView back to your app (e.g., user actions or analytics), this guide will walk you through the necessary setup and best practices for efficient, secure, and reliable communication.

Receiving Messages

React Native listens for messages using the onMessage prop of the WebView:

<WebView
  source={{ uri: 'https://{clientId}.loveslisa.tech/s/{showId}' }}
  onMessage={(event) => {
    const message = JSON.parse(event.nativeEvent.data);
    console.log('Received message from React.js:', message);
  }}
/>

Sending Messages

React Native allows sending messages to the embedded web app using the injectJavaScript or evaluateJavaScriptprops of the WebView.

const webViewRef = useRef(null);

const sendMessageToWebApp = () => {
  const message = JSON.stringify({
    type: 'event',
    payload: { key: 'value' },
  });

  webViewRef.current?.injectJavaScript(`
    window.postMessage(${message}, '*');
  `);
};

return (
  <WebView
    ref={webViewRef}
    source={{ uri: 'https://{clientId}.loveslisa.tech/s/{showId}' }}
    javaScriptEnabled={true}
  />
);
  • The WebView is wrapped in a ref (webViewRef), allowing programmatic control.

  • When sendMessageToWebApp is called, it injects JavaScript into the LiSA Player using injectJavaScript.

  • The message is sent as a JSON object via window.postMessage.

PreviousReact NativeNextStorage

Last updated 3 months ago