CB-9445 Improves executeScript callbacks on iOS

This closes #125

Signed-off-by: Shazron Abdullah <shazron@apache.org>
This commit is contained in:
sgrebnov 2015-11-20 19:15:55 +03:00 committed by Shazron Abdullah
parent 290ea0ac9c
commit 65821f907d
2 changed files with 2 additions and 7 deletions

View File

@ -30,7 +30,6 @@
@class CDVInAppBrowserViewController; @class CDVInAppBrowserViewController;
@interface CDVInAppBrowser : CDVPlugin { @interface CDVInAppBrowser : CDVPlugin {
BOOL _injectedIframeBridge;
} }
@property (nonatomic, retain) CDVInAppBrowserViewController* inAppBrowserViewController; @property (nonatomic, retain) CDVInAppBrowserViewController* inAppBrowserViewController;

View File

@ -266,11 +266,8 @@
- (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper - (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper
{ {
if (!_injectedIframeBridge) { // Ensure an iframe bridge is created to communicate with the CDVInAppBrowserViewController
_injectedIframeBridge = YES; [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)"];
// 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)"];
}
if (jsWrapper != nil) { if (jsWrapper != nil) {
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:@[source] options:0 error:nil]; NSData* jsonData = [NSJSONSerialization dataWithJSONObject:@[source] options:0 error:nil];
@ -407,7 +404,6 @@
- (void)webViewDidStartLoad:(UIWebView*)theWebView - (void)webViewDidStartLoad:(UIWebView*)theWebView
{ {
_injectedIframeBridge = NO;
} }
- (void)webViewDidFinishLoad:(UIWebView*)theWebView - (void)webViewDidFinishLoad:(UIWebView*)theWebView