Skip to content

Instantly share code, notes, and snippets.

@EvDevNinja
EvDevNinja / WebViewBridge.js
Last active February 27, 2019 18:16
Provides a sample implementation for sending and receiving messages to and from the React-Native WebView (using postMessage/onMessage WebView API).
/**
* Created by Guy Blank on 3/9/17.
* https://gist.github.com/blankg/d5537a458b55b9d15cb4fd78258ad840
* Updated to support async in ReactNative by EvDevNinja on 2018.04.26
* https://gist.github.com/EvDevNinja/f3979e00c5f0734297fae5ed79f850b8
*
* This is a sample provides an API to send & receive messages to and from the React-Native WebView (using postMessage/onMessage WebView API).
*
* webViewBridge.send('functionToInvoke', {mydata: 'test'}, function(){console.log('success')},function(){console.log('error')});
*