You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2018/12/05 09:12:25 UTC

[GitHub] dpa99c commented on a change in pull request #362: (iOS & Android) Add postMessage API support

dpa99c commented on a change in pull request #362: (iOS & Android) Add postMessage API support
URL: https://github.com/apache/cordova-plugin-inappbrowser/pull/362#discussion_r238981263
 
 

 ##########
 File path: src/ios/CDVUIInAppBrowser.m
 ##########
 @@ -348,9 +358,6 @@ - (void)loadAfterBeforeload:(CDVInvokedUrlCommand*)command
 
 - (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper
 {
-    // Ensure an iframe bridge is created to communicate with the CDVUIInAppBrowserViewController
-    [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)"];
 
 Review comment:
   > Is `createIframeBridge` equal to this?
   Yes, this code has been factorised out into `createIframeBridge`
   
   > Is it safe to move this to where `createIframeBridge` is called now?
   In this original implementation, the iframe bridge is created "on demand", the first time that an injection method (such as `injectScriptCode`) is called. Subsequent calls find the iframe bridge already exists, so it's only created once.
   
   In the new implementation, `createIframeBridge` is called after every successful page load (`webViewDidFinishLoad` to ensure the bridge always exists, regardless of whether an injection method has been called. This enables pages contained within the IAB Webview to make use to the bridge in order to send `message` events back to the app Webview, without relying on an injection method having been previously called in order to create the bridge.
   
   Therefore, I think it's safe enough to do this.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org