Install and open native Android / ios app in javascript / Angular JS

We have a crawl button in our mobile web application. The mobile web application fully supports HTML5 and Angular JS and javascript / ajax. We need to install a third-party application for scanning applications from Google Play / iTunes based on the Android Android / Iphone agent, and if the application is already installed, we need to open it when the user clicks the scan button. Please suggest any solution in the 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 questions. Many times it redirects to googleplay / itunes, although the application is installed, and sometimes when the application is not installed, it opens myapp://custom-scheme-url , and then immediately gives an error, for example, "this web page is not available." We also tried using different timeout values, but did not help.

Please indicate if there is any way other than setting a timeout to check whether the application is installed or not.

+4
source share
1 answer

Part of your problem can be solved with an iframe . See this ticket for more details.

In particular:

If you need to open an iOS application, if it is installed, and also want to keep your page functionality, location.href =? MyApp: // PARAMS = ... '; does not help, because if myapp: // is not registered, redirection leads the user to an inaccessible destination.

Decision:

 var frame = document.createElement('iframe'); frame.src = 'myapp://?params=...'; frame.style.display = 'none'; document.body.appendChild(frame); 
0
source

Source: https://habr.com/ru/post/1496006/


All Articles