From 4c34caa104e2213928dcbfe862ed2aba1119b89a Mon Sep 17 00:00:00 2001 From: Kamil Burczyk Date: Thu, 3 Apr 2014 14:26:17 +0200 Subject: [PATCH] Updated Readme with custom bundle example --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 5af2b3ce..5012ff33 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,23 @@ Example: NSLog(@"Current UIWebView page URL is: %@", responseData); }]; +#### Custom bundle +`WebViewJavascriptBridge` requires `WebViewJavascriptBridge.js.txt` file that is injected into web view to create a bridge on JS side. Standard implementation uses `mainBundle` to search for this file. If you e.g. build a static library and you have that file placed somewhere else you can use this method to specify which bundle should be searched for `WebViewJavascriptBridge.js.txt` file: + +##### `[WebViewJavascriptBridge bridgeForWebView:(UIWebView/WebView*)webView webViewDelegate:(UIWebViewDelegate*)webViewDelegate handler:(WVJBHandler)handler resourceBundle:(NSBundle*)bundle` + +Example: + + +``` +[WebViewJavascriptBridge bridgeForWebView:_webView + webViewDelegate:self + handler:^(id data, WVJBResponseCallback responseCallback) { + NSLog(@"Received message from javascript: %@", data); + } + resourceBundle:[NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:@"ResourcesBundle" withExtension:@"bundle"]] +]; +``` ### Javascript API