We have "scan" button in our mobile Web application.The mobile web application is completely HTML5 and Angular JS and javascript/ajax based. We need to install some third party native scanning application from Google Play/iTunes based on user Agent Android/Iphone and if application is already installed we need to open it when user clicks scan button. Please suggest any solution in javascript/Angular JS.Below solution I tried
setTimeout(function() {
window.location = 'http://my-installation.url'; //to download
}, 1000);
window.location = 'myapp://custom-scheme-url'; //to open
But this approach is full of issues. Many times it is redirecting to googleplay/itunes although the application is installed and sometimes when application is not installed it is opening myapp://custom-scheme-url
and then immediately giving error like "this web page is not available error". We tried with different values of timeout as well but was not helpful.
Please suggest if there is any way apart from setting timeout to check if app is already installed or not.