When users enter my mobile website, I want to detect that a user installed my specific app or not, then If it installed, I want to redirect my user to my native app.
I tried below
HTML
<a class="intent" href="http://mymobilewebsite" data-scheme="myApp://"></a>
Javascript
(function () {
goToUri($("a.intent").data('scheme'), $("a.intent").attr('href'));
event.preventDefault();
function goToUri(uri, href) {
var start, end, elapsed;
start = new Date().getTime();
document.location = uri;
end = new Date().getTime();
elapsed = (end - start);
if (elapsed < 1) {
document.location = href;
}
}
})();
this does not work at all.
I searched how youtube does that because I know when I type youtube ton google and click youtube's mobile website link, android asking me to perform to complete that action on youtube app.
How youtube achieve that perform, could not find out ?
Edit : My Question pointed as duplicated, in my question, I am asking that I want to solve this problem only in mobile website