(ios) Move createIframeBridge to injectDeferredObject

Avoid failed script injections for pages which did not finish loading.
This commit is contained in:
Niklas Merz 2019-01-16 14:18:35 +01:00
parent 632a395b3d
commit e3db974080

View File

@ -362,6 +362,7 @@ static CDVUIInAppBrowser* instance = nil;
- (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper
{
[self createIframeBridge];
if (jsWrapper != nil) {
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:@[source] options:0 error:nil];
NSString* sourceArrayString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
@ -564,7 +565,6 @@ static CDVUIInAppBrowser* instance = nil;
- (void)webViewDidFinishLoad:(UIWebView*)theWebView
{
[self createIframeBridge];
if (self.callbackId != nil) {
// TODO: It would be more useful to return the URL the page is actually on (e.g. if it's been redirected).
NSString* url = [self.inAppBrowserViewController.currentURL absoluteString];