All Projects → lesnitsky → React Native Webview Messaging

lesnitsky / React Native Webview Messaging

Licence: mit
✉️ Send/Receive data between React Native app and WebView

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Native Webview Messaging

Jstarcraft Core
目标是提供一个通用的Java核心编程框架,作为搭建其它框架或者项目的基础. 让相关领域的研发人员能够专注高层设计而不用关注底层实现. 涵盖了缓存,存储,编解码,资源,脚本,监控,通讯,事件,事务9个方面.
Stars: ✭ 150 (-40.24%)
Mutual labels:  event, communication
Rxbus
Android reactive event bus that simplifies communication between Presenters, Activities, Fragments, Threads, Services, etc.
Stars: ✭ 79 (-68.53%)
Mutual labels:  event, communication
Gear Lib
Gear-Lib, C library for IOT Embedded Multimedia and Network
Stars: ✭ 2,381 (+848.61%)
Mutual labels:  event
React Native Add Calendar Event
Create, view or edit events in react native using the standard iOS / Android dialogs
Stars: ✭ 225 (-10.36%)
Mutual labels:  event
Juggle
juggle是一个极简的、组件式的js框架。无依赖,完美闭包,灵活且适合渐进学习,可与任何框架整合。包含(支持冒泡的事件 || Tween || MV框架 || http || websocket || 资源 || 模块)等组件,按需选择组件,不绑架开发者。
Stars: ✭ 208 (-17.13%)
Mutual labels:  event
October30
macOS Screen Saver showing 371 Apple logos from their 2018 iPad event
Stars: ✭ 200 (-20.32%)
Mutual labels:  event
React Native Webview Invoke
Invoke functions between React Native and WebView
Stars: ✭ 211 (-15.94%)
Mutual labels:  webview
Android Youtube Player
YouTube Player library for Android and Chromecast, stable and customizable.
Stars: ✭ 2,510 (+900%)
Mutual labels:  webview
Restcomm Connect
The Open Source Cloud Communications Platform
Stars: ✭ 232 (-7.57%)
Mutual labels:  communication
Dc Sdk
DC-SDK 是基于 Cesium 进行二次开发的2、3D一体 WebGis 应用框架,该框架优化了 Cesium 的使用方式和增添了一些额外功能,旨在为开发者快速构建 WebGis 应用。🌎
Stars: ✭ 206 (-17.93%)
Mutual labels:  event
Comms champion
C++(11) library to implement and tools to monitor binary communication protocols
Stars: ✭ 225 (-10.36%)
Mutual labels:  communication
Tauri
Build smaller, faster, and more secure desktop applications with a web frontend.
Stars: ✭ 25,383 (+10012.75%)
Mutual labels:  webview
Adamant Im
ADAMANT Decentralized Messenger. Progressive Web Application (PWA)
Stars: ✭ 202 (-19.52%)
Mutual labels:  communication
Unpeek Livedata
LiveData 数据倒灌:别问,问就是不可预期 - Perfect alternative to SingleLiveEvent, supporting multiple observers.
Stars: ✭ 208 (-17.13%)
Mutual labels:  event
Evmongoose
DEPRECATED. Evmongoose is an asynchronous, event(libev) based multi-protocol embedded networking library with functions including TCP, HTTP, WebSocket, MQTT and much more. It's based on mongoose and libev implementation and it's support Lua API.
Stars: ✭ 199 (-20.72%)
Mutual labels:  event
Medium Zoom
🔎🖼 A JavaScript library for zooming images like Medium
Stars: ✭ 2,799 (+1015.14%)
Mutual labels:  event
Hazel Networking
Hazel Networking is a low level networking library for C# providing connection orientated, message based communication via TCP, UDP and RUDP.
Stars: ✭ 194 (-22.71%)
Mutual labels:  communication
Kap
An open-source screen recorder built with web technology
Stars: ✭ 14,488 (+5672.11%)
Mutual labels:  communication
Recaptcha
[In]visible ReCaptcha v2 for iOS
Stars: ✭ 208 (-17.13%)
Mutual labels:  webview
Modbus.net
A high extensible hardware communication platform using C#
Stars: ✭ 244 (-2.79%)
Mutual labels:  communication

React Native WebView Messaging

React Native WebView extension with 2-way event-based communication API

GitHub stars Twitter Follow

⚠️ this is v2 branch which is not yet stable. Check out v1 branch for v1 docs

Installation

npm install [email protected]

Examples

Examples

Usage

React Native

import React, { Component } from 'react';
import { View, TouchableHighlight } from 'react-native';
import { connectToRemote, WebView } from 'react-native-webview-messaging';

export class ExampleView extends Component {
  render() {
    return (
      <View>
        <WebView
          ref={ webview => { this.webview = webview; }}
          source={ require('./some-page.html') }
        />
        <TouchableHighlight onPress={this.sendMessageToWebView} underlayColor='transparent'>
          <Text>Send message to WebView</Text>
        </TouchableHighlight>
      </View>
    )
  }

  async componentDidMount() {
    this.remote = await connectToRemote(this.webview);

    this.remote.on('text', text => console.log(text));
    this.remote.on('json', json => console.log(json));
    this.remote.on('custom-event-from-webview', eventData => console.log(eventData));
  }

  sendMessageToWebView = () => {
    this.remote.sendJSON({
      payload: 'JSON from RN'
    });

    this.remote.send('plain text from RN');

    this.remote.emit('custom-event-from-rn', { payload: 'Custom event from RN' });
  }
}

Web

import { connectToRemote } from 'react-native-webview-messaging/web';

connectToRemote()
  .then(remote => {
    remote.on('text', text => console.log(text));
    remote.on('json', json => console.log(json));
    remote.on('custom-event-from-rn', data => console.log(data));

    remote.send('plain text from WebView');
    remote.sendJSON({
      payload: 'JSON from WebView'
    });

    remote.emit('custom-event-from-webview', { payload: 'Custom event from WebView' });
  });

LICENSE

MIT

GitHub stars Twitter Follow

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].