当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - How is it possible to check from safari if an app is installed on the device

问题描述:

Our application opens from javascript in safari browser in the following way:

window.location = appname://?viewcontent=c_187185

Using the above mention method to call the app which is not currently installed on the device produces the following popup:

"Can not Open Page. Safari can not open the page because the address is invalid"

Before iOS 9.1 update such popup served as an indication that the application was not installed. Based on this there were several workarounds by using setTimeout () function, for example:

 var now = new Date (). valueOf ();

setTimeout (function () {

if (new Date (). valueOf () - now> 100) return;

window.location = "https://itunes.apple.com/appdir";

} 25);

window.location = "appname: //";

But after the upgrade to iOS 9.1 in the case of calling the app there is an additional dialog box pops up that asks the user whether or not to open the application. Because of this, the above stated workaround no longer works since the dialog pop up appears regardless of whether there is an application in the system or not.

How is it now possible to check from safari if an app is installed on the device and what will happen if there is a need to check and call different apps from the same web page in safari?

分享给朋友:
您可能感兴趣的文章:
随机阅读: