From dcecc1186719bd701a753360478c99835026fa2a Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 27 Aug 2014 13:10:56 -0400 Subject: [PATCH] Remove WebViewJavascriptBridge `-reset` method. It is unreliable and should not be used. See GH issue #99 --- Changelog | 3 +++ .../WebViewJavascriptBridge.h | 1 - .../WebViewJavascriptBridge.m | 16 +++++++++------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Changelog b/Changelog index b19f6cfe..9553abaf 100644 --- a/Changelog +++ b/Changelog @@ -13,6 +13,9 @@ Release Checklist Version History --------------- +Intended v5.0.0 ++ Removed `WebViewJavascriptBridge -reset`. It should never have been exposed as a public API. + v4.1.4 + Improve how WVJB handles the case when there is no ObjC handler for a message received from js. + If an objc handler throws and exception, let it bubble up to the webkit engine instead of catching it in WVJB. diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.h b/WebViewJavascriptBridge/WebViewJavascriptBridge.h index 6b0334b1..9e90829f 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.h @@ -39,6 +39,5 @@ typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback); - (void)callHandler:(NSString*)handlerName; - (void)callHandler:(NSString*)handlerName data:(id)data; - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback; -- (void)reset; @end diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.m b/WebViewJavascriptBridge/WebViewJavascriptBridge.m index 388b0494..04ab38ee 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.m @@ -51,7 +51,6 @@ + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WV { WebViewJavascriptBridge* bridge = [[WebViewJavascriptBridge alloc] init]; [bridge _platformSpecificSetup:webView webViewDelegate:webViewDelegate handler:messageHandler resourceBundle:bundle]; - [bridge reset]; return bridge; } @@ -79,15 +78,18 @@ - (void)registerHandler:(NSString *)handlerName handler:(WVJBHandler)handler { _messageHandlers[handlerName] = [handler copy]; } -- (void)reset { - _startupMessageQueue = [NSMutableArray array]; - _responseCallbacks = [NSMutableDictionary dictionary]; - _uniqueId = 0; -} - /* Platform agnostic internals *****************************/ +- (id)init { + if (self = [super init]) { + _startupMessageQueue = [NSMutableArray array]; + _responseCallbacks = [NSMutableDictionary dictionary]; + _uniqueId = 0; + } + return self; +} + - (void)dealloc { [self _platformSpecificDealloc];