File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -106,7 +106,13 @@ - (void)_dispatchMessage:(NSDictionary *)message {
106106 messageJSON = [messageJSON stringByReplacingOccurrencesOfString: @" \n " withString: @" \\ n" ];
107107 messageJSON = [messageJSON stringByReplacingOccurrencesOfString: @" \r " withString: @" \\ r" ];
108108 messageJSON = [messageJSON stringByReplacingOccurrencesOfString: @" \f " withString: @" \\ f" ];
109- [_webView stringByEvaluatingJavaScriptFromString: [NSString stringWithFormat: @" WebViewJavascriptBridge._handleMessageFromObjC('%@ ');" , messageJSON]];
109+ if ([[NSThread currentThread ] isMainThread ]) {
110+ [_webView stringByEvaluatingJavaScriptFromString: [NSString stringWithFormat: @" WebViewJavascriptBridge._handleMessageFromObjC('%@ ');" , messageJSON]];
111+ } else {
112+ dispatch_sync (dispatch_get_main_queue (), ^{
113+ [_webView stringByEvaluatingJavaScriptFromString: [NSString stringWithFormat: @" WebViewJavascriptBridge._handleMessageFromObjC('%@ ');" , messageJSON]];
114+ });
115+ }
110116}
111117
112118- (void )_flushMessageQueue {
You can’t perform that action at this time.
0 commit comments