cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Grebnov (JIRA)" <>
Subject [jira] [Commented] (CB-9445) executeScript callbacks not working for iOS
Date Thu, 19 Nov 2015 11:24:11 GMT


Sergey Grebnov commented on CB-9445:

Here is my code (no other changes)

- (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper
    NSLog(@"injectDeferredObject source: %@; wrapper: %@", source, jsWrapper);

    // Ensure an iframe bridge is created to communicate with the CDVInAppBrowserViewController
    [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:@"(function(d){if(document.getElementById('_cdvIframeBridge'))
return; var e = _cdvIframeBridge = d.createElement('iframe');'_cdvIframeBridge';'none';d.body.appendChild(e);})(document)"];

    if (jsWrapper != nil) {
        NSData* jsonData = [NSJSONSerialization dataWithJSONObject:@[source] options:0 error:nil];
        NSString* sourceArrayString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        if (sourceArrayString) {
            NSString* sourceString = [sourceArrayString substringWithRange:NSMakeRange(1,
[sourceArrayString length] - 2)];
            NSString* jsToInject = [NSString stringWithFormat:jsWrapper, sourceString];
            NSLog(@"stringByEvaluatingJavaScriptFromString %@", jsToInject);
            [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:jsToInject];
    } else {
        [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:source];

> executeScript callbacks not working for iOS
> -------------------------------------------
>                 Key: CB-9445
>                 URL:
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin InAppBrowser
>    Affects Versions: 5.1.1
>         Environment: Cordova 5.1.1 (CLI), ios 3.8.0, android 4.0.2, cordova-plugin-inappbrowser
1.0.1 (NPM)
>            Reporter: Scott Seitz
>            Assignee: jcesarmobile
>              Labels: Triaged, iOS
> Can someone please check to see if they are encountering the same problem I am in the
environment I've listed? (latest released builds of everything I think)
> I open an inappbrowser window and then run an executeScript command using "code:" (not
"file:").  Everything works fine on Android, but on iOS, it simply will NOT fire the callback
function after executing the injected code.  Make the "code:" as simple as you like to test
it and see if you can get a callback to fire.  I've dumbed it down as much as possible and
can't get one to fire.  I know that all instances of code I've injected have run fine in the
iab by using the console (against the iab) to check for the variables I was creating in the
code.  I can't even get a callback to fire that doesn't expect a parameter to be passed back...
> Many thanks,
> Scott

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message