web-bridge-gateway
v1.0.5
Published
web bridge gateway is bridge communication between native and webview.
Downloads
120
Readme
Web Bridge Gateway
Web-Bridge-Gateway is a wrapper of WebviewJavascriptBridge
Install
yarn
yarn add web-bridge-gateway
npm
npm i web-bridge-gateway
Configurations (Options)
| Key | Type | Default | Description |
| ------- | ------- | ------- | ----------------------------------------------------------------------------------------------------------------- |
| delay | Number | 200
| The processing of registerHandler failure caused by birdge initialization takes time, delay call time, value ms
|
Methods
callHandler
- description: Communicate between native app and mini app. The first parameter is the name provided by native app, the second parameter (optional) is the request body.
import { callHandler } from 'web-bridge-gateway' callHandler("setBarTitle", { title: "Home Page" }) .then(() => { // do something }) .catch(() => { // handle error });
registerHandler
- description: Register a handler for listening to native app call. The first parameter a name that will be provided by native app, the second parameter is a callback function (optional).
import { registerHandler } from 'web-bridge-gateway' registerHandler("myListener", (data, callback) => { console.log("data from native:", data); callback('callback to native'); });