TGJSBridge 0.2.1

TGJSBridge 0.2.1

TestsTested
LangLanguage Obj-CObjective C
License BSD
ReleasedLast Release Dec 2014

Maintained by Unclaimed.


Downloads

Total574
Week0
Month0

Installs

Apps13
Watch Apps1
powered by Segment

GitHub

Stars133
Watchers12
Forks33
Issues0
Contributors1
Pull Requests0

Code

Files2
LOCLines of Code 164


  • By
  • Chao Shen

TGJSBridge is a lightweight javascript bridge to cocoa. TGJSBridge is iOS4 and iPad compatible.

Usage in objective-c

Init jsBridge

TGJSBridge *jsBridge = [TGJSBridge jsBridgeWithDelegate: webViewDelegate];
webView.delegate = jsBridge;

Send notification to javascript

postNotificationName:userInfo:toWebView:

Listen notification from javascript

- (void)jsBridge:(TGJSBridge *)bridge didReceivedNotificationName:(NSString *)name userInfo:(NSDictionary *)userInfo fromWebView:(UIWebView *)webview

Usage in webview

Send notification to cocoa

jsBridge.postNotification(msgName,userInfo);

Listen notification from cocoa

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

Cancel listening notification from cocoa

jsBridge.unbind('test',callbackHandler);

LICENSE

Copyright (c) 2012 Chao Shen(Hangzhou Jiuyan Technology Co., Ltd.). This software is licensed under the BSD License.