I am trying to open a android application from javascript. If the android application is installed in android mobile, it opens required application. But if android application is not installed, it should give me the popup saying, "You do not seem to have app installed, do you want to download it now?". But I am getting net::ERR_UNKNOWN_URL_SCHEME error. I have added the code snippet below:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript">
function redirectToApp() {
$('#link').attr('href', "<scheme>://<package>/?<parameters>");
$("#link")[0].click();
setTimeout(
function() {
if (confirm('You do not seem to have app installed, do you want to download it now?')) {
window.location = 'https://play.google.com/store/apps/details?id=123';
}
}, 500);
}
</script>
</head>
<body onload="redirectToApp()">
<a id="link" href="" style="display: none">Link</a>
</body>
</html>