You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
document.addEventListener('WebViewJavascriptBridgeReady', function onBridgeReady(bridge) {
39
+
bridge.init(function(message, responseCallback) {
45
40
alert('Received message: ' + message)
46
41
if (responseCallback) {
47
42
responseCallback("Right back atcha")
48
43
}
49
44
})
50
-
WebViewJavascriptBridge.send('Hello from the javascript')
45
+
bridge.send('Hello from the javascript')
51
46
}, false)
52
47
53
-
iOS4 support (with JSONKit)
54
-
---------------------------
55
-
56
-
*Note*: iOS4 support has not yet been tested in v2.
57
-
58
-
WebViewJavascriptBridge uses `NSJSONSerialization` by default. If you need iOS 4 support then you can use [JSONKit](https://github.com/johnezang/JSONKit/), and add `USE_JSONKIT` to the preprocessor macros for your project.
59
-
60
48
API Reference
61
49
-------------
62
50
@@ -121,57 +109,66 @@ Example:
121
109
122
110
### Javascript
123
111
124
-
##### `document.addEventListener('WebViewJavascriptBridgeReady', function onBridgeReadyHandler() { ... }, false)`
112
+
##### `document.addEventListener('WebViewJavascriptBridgeReady', function onBridgeReady(bridge) { ... }, false)`
125
113
126
-
Always wait for the `WebViewJavascriptBridgeReady` DOM event before using `WebViewJavascriptBridge`.
114
+
Always wait for the `WebViewJavascriptBridgeReady` DOM event.
Initialize the WebViewJavascriptBridge. This should be called inside of the `'WebViewJavascriptBridgeReady'` event handler.
124
+
Initialize the bridge. This should be called inside of the `'WebViewJavascriptBridgeReady'` event handler.
137
125
138
126
The `messageHandler` function will receive all messages sent from ObjC via `[bridge send:(id)data]` and `[bridge send:(id)data responseCallback:(WVJBResponseCallback)responseCallback]`.
139
127
140
128
The `responseCallback` will be a function if ObjC sent the message with a `WVJBResponseCallback` block, or `undefined` otherwise.
Register a handler called `handlerName`. The ObjC can then call this handler with `[bridge callHandler:"handlerName" data:@"Foo"]` and `[bridge callHandler:"handlerName" data:@"Foo" responseCallback:^(id responseData) { ... }]`
*Note*: iOS4 support has not yet been tested in v2.
168
+
169
+
WebViewJavascriptBridge uses `NSJSONSerialization` by default. If you need iOS 4 support then you can use [JSONKit](https://github.com/johnezang/JSONKit/), and add `USE_JSONKIT` to the preprocessor macros for your project.
0 commit comments