Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes iOSDispatcher to use iframes to dispatch events #19

Merged
merged 1 commit into from
Jul 22, 2014

Conversation

guidomb
Copy link
Contributor

@guidomb guidomb commented Mar 2, 2014

Instead of using window.location.href to trigger
the webView:shouldStartLoadWithRequest:navigationType:
in the UIWebView's delegate now it creates a new
iframe and set its source to the same URL
usend in window.location.href.

This is done because I was doing several calls to the native code and only the last one was reaching. Using iframes make it work

Instead of using window.location.href to trigger
the webView:shouldStartLoadWithRequest:navigationType:
in the UIWebView's delegate now it creates a new
iframe and set its source to the same URL
usend in window.location.href.
@tcoulter
Copy link
Owner

tcoulter commented Mar 2, 2014

Hi @guidomb. Thanks for the pull request, and this sounds like a great change. I can't make the change until I test it out on the Android side, which I don't have readily available. Once I get something set up, I'll let you know. Let's keep this PR open.

Do you know what other functions were being called in native code?

Thanks again.

@guidomb
Copy link
Contributor Author

guidomb commented Mar 2, 2014

What do you mean by "other functions were being called in native code". Maybe I didn't make my self clear. This is what was happening to me.

I had this Javascript code loaded in my index.html

(function(){

var Logger = {
  debug: function(message) {
    Jockey.send("debug", {message: message});
  }
}

Logger.debug("Message 1");
Logger.debug("Message 2");
Logger.debug("Message 3");

})();

and in the iOS side:

[Jockey on:@"debug" perform:^(NSDictionary * payload){
  DDLogDebug(@"UIWebView: %@", [payload objectForKey:@"message"]);
}];

The output on the debug console was only Message 3. That is when I thought that it may be related on how the UIWebView handles the window.location function. Doing some googling I found that the recommended way was to use an iframe. So I made the change and then all the messages were shown on the console.

@AppsIncorporated
Copy link

for info on why this is important, see: http://stackoverflow.com/questions/9473582/ios-javascript-bridge

@tcoulter
Copy link
Owner

Sorry for the late response on this. Merging. Thanks for the PR.

@tcoulter tcoulter merged commit f5cd3e7 into tcoulter:master Jul 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants