Version Pod License iOS 8.0+ ARC
- Blog :
- v1.1.0 : 强化安全管理,增加安全插件,不配置不影响正常使用。配置方式参照DEMO。
- 一行代码集成。
- 异步调用。
- 支持业务模块化分离。
- 支持业务模块白名单机制,提升安全性。
- 1、:
在Podfile文件里面添加:pod 'WKJavaScriptBridge'- 2、:对应文件添加头文件
#import "WKJavaScriptBridge.h"
-
1、下载WKJavaScriptBridge,将WKJavaScriptBridge文件夹拖入到你的工程中
-
2、引入头文件:
#import "WKJavaScriptBridge.h"
- 1、:
//在使用Bridge的类扩展中加入
@property (nonatomic, strong) WKJavaScriptBridge *bridge;- 2、:
//在创建WKWebView的地方调用此方法,绑定你的WebView self.bridge = [WKJavaScriptBridge bindBridgeWithWebView:yourwebView];
- 3、:
h5页面引入:<script type="text/javascript" src="WKJSBridge.js" ></script>
- 4、:
//H5调用Native: window.WKJSBridge.callNative(service, action, command, function success(res) {}, function fail(res) {}); service:Native类名 action:Native方法名 command:参数 function success(res) {}:成功回调函数 function fail(res) {}:失败回调函数 //Native回调H5: - (void)sendPluginResult:(WKPluginResult *)result callbackId:(NSString*)callbackId; result:参数 callbackId:H5传过来的回调ID
构建小程序
WKJavaScriptBridge is available under the Apache License 2.0. See the LICENSE file for more info.