Hacker News new | ask | show | jobs
by Connorhd 5225 days ago
I'm not quite sure I understand what you mean (so if this is the wrong answer let us know). But if you mean why do we use a different method on Android compared to iOS: we can communicate directly from Javascript to Java as part of the WebView in Android, which is very fast. The URL interception method is actually the slowest part of iOS but there is no way around it.
2 comments

You can call Objective-C from JavaScript on iOS: [ https://developer.apple.com/library/mac/#documentation/Apple... ]
I believe this is a Mac OS X feature that isn't supported on iOS.
Thanks for the answer. Sorry I wasn't clear... I was referring to this part of the article, in which you describe how the HTML / JavaScript communicates with Objective C on the iPhone:

>> We then make a request to a fake URI (forge://…) which we intercept in native code

Have you tried doing the same for Android? Do you have any numbers that compare the performance of this method with the JS -> Java bridge?

Ok, that makes sense, the JS -> Java communication in Android is already very fast as it is something that can be done as part of the WebView. The fake URI request is a workaround on iOS as this feature doesn't exist. I don't have any numbers offhand, but the JS -> Java communication is definitely a very quick part of the bridge.