Closed ghost closed 10 years ago
I found the root of the problem as well as the solution. In the latest js of the library you included the following code:
if (iOS && UIWebView) { Jockey.dispatcher = iOSDispatcher; } else { Jockey.dispatcher = nullDispatcher; }
Unfortunately in Android the dispatcher used was the nullDispatcher so nothing was been send to the app. After almost going nuts why your sample application was working was due to the fact that actually in the library included in the sample project the code looked like this.
// if (iOS && UIWebView) { Jockey.dispatcher = iOSDispatcher; // } else { // Jockey.dispatcher = nullDispatcher; // }
So the iOSDispatcher was always been used. After looking at the code I am not sure why do you even need to distinguish between iOS and Android. The dispatch method inside the iOSDispatcher has the following line of code:
window.location.href = "jockey://" + type + "/" + envelope.id + "?" + encodeURIComponent(JSON.stringify(envelope));
This might cause issues but actually you already solved it in the Android library with this: public boolean isJockeyScheme(URI uri) { return uri.getScheme().equals("jockey") && !uri.getQuery().equals(""); }
So yo actually detect the redirection in the Android JockeyWebViewClient() so it is handled correctly. So I would recommend updating the JS library code as it is really confusing and it seems to be working correctly by using always the iOSDispatcher.
Again thanks for the work done.
Wow @jatago, thanks for finding this. The original JS was written by me when I assumed there would need to be a different dispatcher for Android. Another fine coder came along and filled out the android work not needing a new dispatcher, and I guess the JS never got updated.
Would you mind submitting a PR? I'd love to have this change in there.
Hi Tim!
Sure no problem ;) thanks to you guys for writing this library. Super simple to use and extremely helpful! On Jan 23, 2014 5:38 PM, "Tim Coulter" notifications@github.com wrote:
Wow @jatago https://github.com/jatago, thanks for finding this. The original JS was written by when I assumed there would need to be a different dispatcher for Android. Another fine coder came along and filled out the android not needing a new dispatcher, and I guess the JS never got updated.
Would you mind submitting a PR? I'd love to have this change in there.
— Reply to this email directly or view it on GitHubhttps://github.com/tcoulter/jockeyjs/issues/18#issuecomment-33141548 .
This should be fixed by #20
Awesome, thanks @paulpdaniels. Closing.
Hello,
First thanks for the library. Amazing job. Second able, I don't quite follow the issue here. So I tried your sample Android app and seems to be working correctly so I can send events from the JS and receive them in the Android app. But now when I take my website js which is loaded from a remote server, add the send method with the custom event and listen to it in the Android app, nothing gets trigger (In the iOS app seems to be working perfect). This happens with your Android sample app as well as my Android application.
Thanks