javascript-native-bridge
v1.0.0
Published
a webview jsBridge for native
Downloads
8
Maintainers
Readme
jsBridge
a webview jsBridge for native(ios, Android, react-native)
Installation
npm install javascript-native-bridge --save
Usage for frontEnd
import createNativeBridge from 'jsBridge'
// eg: nativeBridge
// ios: window.webkit.messageHandlers.nativeBridge
// Android: window.nativeBridge
// rn: window.ReactNativeWebView
createNativeBridge(BridgeName = 'jsBridge', nativeBridge = window.ReactNativeWebView)
jsBridge.invoke(type, data)
Usage for afterEnd
对于 ios 的 WKWebview
[wkWebView evaluateJavaScript:javaScriptString completionHandler:completionHandler];
对于 Android 的 Kitkat(4.4)之后版本
webView.evaluateJavascript(javaScriptString, new ValueCallback<String>() {
@Override
publicvoidonReceiveValue(String value){
}
})