代码开源在:OC中初始化:

1
2
TGJSBridge *jsBridge = [TGJSBridge jsBridgeWithDelegate: webViewDelegate];
<u><font color="\"red\"">webView</font></u>.delegate = jsBridge;



发消息到JS:

1
postNotificationName:userInfo:toWebView:



监听消息:

1
- (void)jsBridge:(TGJSBridge *)bridge didReceivedNotificationName:(NSString *)name userInfo:(NSDictionary *)userInfo fromWebView:(UIWebView *)<u><font color="\"red\"">webview</font></u>





js发送消息:

1
jsBridge.postNotification(msgName,userInfo);





js监听消息:

1
2
3
jsBridge.bind(msgName, function(userInfo){
    ...
});




js取消监听消息:

1
jsBridge.unbind('test',callbackHandler);
 

相关文章:

  • 2022-01-25
  • 2021-06-29
  • 2022-12-23
  • 2021-09-01
  • 2021-05-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2021-10-10
相关资源
相似解决方案