From 65821f907d622528f80153ecd24630d483742a69 Mon Sep 17 00:00:00 2001 From: sgrebnov Date: Fri, 20 Nov 2015 19:15:55 +0300 Subject: [PATCH] CB-9445 Improves executeScript callbacks on iOS This closes #125 Signed-off-by: Shazron Abdullah --- src/ios/CDVInAppBrowser.h | 1 - src/ios/CDVInAppBrowser.m | 8 ++------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/ios/CDVInAppBrowser.h b/src/ios/CDVInAppBrowser.h index 1ccc7b1..6bb0ec1 100644 --- a/src/ios/CDVInAppBrowser.h +++ b/src/ios/CDVInAppBrowser.h @@ -30,7 +30,6 @@ @class CDVInAppBrowserViewController; @interface CDVInAppBrowser : CDVPlugin { - BOOL _injectedIframeBridge; } @property (nonatomic, retain) CDVInAppBrowserViewController* inAppBrowserViewController; diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m index 72effaa..986cfa9 100644 --- a/src/ios/CDVInAppBrowser.m +++ b/src/ios/CDVInAppBrowser.m @@ -266,11 +266,8 @@ - (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper { - if (!_injectedIframeBridge) { - _injectedIframeBridge = YES; - // Create an iframe bridge in the new document to communicate with the CDVInAppBrowserViewController - [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:@"(function(d){var e = _cdvIframeBridge = d.createElement('iframe');e.style.display='none';d.body.appendChild(e);})(document)"]; - } + // Ensure an iframe bridge is created to communicate with the CDVInAppBrowserViewController + [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:@"(function(d){_cdvIframeBridge=d.getElementById('_cdvIframeBridge');if(!_cdvIframeBridge) {var e = _cdvIframeBridge = d.createElement('iframe');e.id='_cdvIframeBridge'; e.style.display='none';d.body.appendChild(e);}})(document)"]; if (jsWrapper != nil) { NSData* jsonData = [NSJSONSerialization dataWithJSONObject:@[source] options:0 error:nil]; @@ -407,7 +404,6 @@ - (void)webViewDidStartLoad:(UIWebView*)theWebView { - _injectedIframeBridge = NO; } - (void)webViewDidFinishLoad:(UIWebView*)theWebView