打包SDK提供给接入方,SDK中嵌套H5页面,使用第三方库WebViewJavascriptBridge与WebView交互,此时需要修改WebViewJavascriptBridge源码,以防接入方中也使用了WebViewJavascriptBridge。修改后使用如下:
@interface DCWebViewJSBridge()
@property (nonatomic,strong)DCWebViewJavascriptBridge_BAXY *bridge;
@end
+ (instancetype)bridgeForWebView:(id)webView andDelegate:(id)webViewDelegate{
DCWebViewJSBridge *jsBridge = [[DCWebViewJSBridge alloc]init];
jsBridge.bridge = [DCWebViewJavascriptBridge_BAXY bridgeForWebView:webView];
[jsBridge.bridge setWebViewDelegate:webViewDelegate];
[DCWebViewJavascriptBridge_BAXY enableLogging];
return jsBridge;
}
-(void)registerFuncName:(DCJSFunctionStringName)funcName handler:(DCWKJBHandler)hander{
[self.bridge registerHandler:funcName handler:^(id data, DCWVJBResponseCallback responseCallback) {
NSLog(@"JS Dict :%@",data);
if (hander) {
hander(data,^(id responseData){
if (responseCallback) {
responseCallback(responseData);
}
});
}
}];
}
修改后的源码地址下载。