Does not open scheme if I call .click() on the link element in Android
Hi, nice plugin. I show a "Click to open app" link on my page. When the user clicks on the link, and the app is installed, the window.location is properly relocated to sheme://... and the app opens (on both iOS and Android).
But I also want to auto-click my own link after a few seconds. So I do:
setTimeout ( function () {
$("#myapplink").click();
}, 5000);
at the end of the body ready function.
It works on iOS. But on Android (Chrome) the window.location assignment in Callback function fails to open the intent. The browser's activity indicator flickers for a short time and then the page goes on to the regular href instead of the scheme://.
I also tried to invoke .trigger("click.applink") on the element instead of .click () to no avail.
Any idea? Thanks Gabriel
And something like:
setTimeout ( function () {
window.location = $("#myapplink").attr('href');
}, 5000);
Well, by definition, the href attribute is the fallback landing page, so, this snippet won't invoke the customscheme://
What I mean, is: if I manually click on the link, it works fine and opens the app (pre-installed of course). If I programmatically click the link (or use window.location), it does not.
Regarding this issue I've faced this problem before too, but this is not an issue from this plugin, this is blocked by Chrome for security reason.
See my answer to the problem: http://stackoverflow.com/questions/31649771/javascript-mailto-not-working-in-chrome-mobile-browser/34528227#34528227
I was finding the same issue, but I fixed the issue by doing it like this, this worked in both Android and iOS platforms now.
<a id="test2" href="javascript:alert('test2')"><span>TEST2</span></a>
$('#test2').find('span').trigger('click'); // Works
Cheers.