如何从Safari中的JS安装应用程序?

时间:2021-03-28 23:54:50

I want to create text on page depend on is my app installed or not.
I already implemented a custom url scheme in app for example:

我想在页面上创建文本取决于我是否安装了我的应用程序。我已经在应用程序中实现了自定义URL方案,例如:

myapp://

but don't know how to check from JS is my app installed or not.
Note: I don't want to run app, just only check.

但不知道如何检查JS是否安装了我的应用程序。注意:我不想运行应用程序,只需检查。

1 个解决方案

#1


1  

It is not possible to detect the app is installed without redirecting to app from javascript.

如果没有从javascript重定向到应用程序,则无法检测到安装的应用程序。

Below code will redirect to the app if installed else callback is called.

如果安装了其他代码,则代码将重定向到应用程序。

setTimeout(function () { 
          //callback if the app is not installed.
}, 25);
window.location = "myapp://somethingyouwanttosend";

You can also take a look at smart banners it might solve your problem.

您还可以查看可能解决问题的智能横幅。

#1


1  

It is not possible to detect the app is installed without redirecting to app from javascript.

如果没有从javascript重定向到应用程序,则无法检测到安装的应用程序。

Below code will redirect to the app if installed else callback is called.

如果安装了其他代码,则代码将重定向到应用程序。

setTimeout(function () { 
          //callback if the app is not installed.
}, 25);
window.location = "myapp://somethingyouwanttosend";

You can also take a look at smart banners it might solve your problem.

您还可以查看可能解决问题的智能横幅。