Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
14 lines (12 sloc) 1.07 KB
intended v2.0.0
+ Messages are objects instead of strings. Supports NSDictionary*/Objects, NSArray*/Arrays, NSNumber*/Number & NSString*/String.
+ Messages are encoded with NSJSONSerialization. Optional fallback to JSONKit for iOS 4 support.
+ Messages can expect responses. A message received with an expected response is accompanied by a WVJBResponseCallback/Function.
+ Handlers can be registered by name, and called with data and an optional expected response.
+ ObjC: A WebViewJavascriptBridge class (a UIWebViewDelegate) that enables message passing to and from the JS
+ ObjC: A protocol called WebViewJavascriptBridgeDelegate that lets you handle messages received from the JS
+ JS: Event when the bridge is ready - document.addEventListener('WebViewJavascriptBridgeReady', function() {}, false)
+ JS: Ability to set your message handler - WebViewJavascriptBridge.setMessageHandler(function() {})
+ JS: Function to send messages - WebViewJavascriptBridge.sendMessage('a message');
+ All messages are strings. Use JSON in your js and e.g. JSONKit in iOS to send structured messages