我怎么知道苹果手机上是否已经安装了Safari浏览器?

时间:2021-08-19 07:11:26

I'd like to know if is it possible to check from Safari via Javascript if there is a specific app already installed. I'm doing a login form for an application from the web that goes into the app and I'd like to call that application. I'm using that code right now:

我想知道如果已经安装了一个特定的应用程序,是否可以通过Javascript来检查Safari。我正在为一个应用程序做一个登录表单,它进入应用程序,我想调用那个应用程序。我现在正在使用这个代码:

{% if request.ios %}
            var backup_url = window.location + "&no_app=True";
              setTimeout( function()
              {
                  document.location = backup_url;
              }, 200);
            window.location = "{{ apple_url }}";
{% endif %}
});

There is a check to know if the device is an iOS device. After that I check if the '&no_app=True' is appended on the url. If it is appended I don't need to check it. Otherwise I have a 200ms where I wait to append it and I try to open the app with: 'window.location = "{{ apple_url }}";'

有一个检查设备是否为iOS设备。在此之后,我检查“&no_app=True”是否在url上附加。如果它被追加,我不需要检查它。否则,我有一个200ms,我在那里等待添加它,我尝试打开应用程序:“窗口”。location = "{apple_url}";

I'd like to track people with Google Analytics so I need to know if the app is installed, in this way I'm just hoping that it is. Do anyone know how to do it?

我想用谷歌分析来追踪人们,所以我需要知道这个应用程序是否已经安装好了,我只是希望它是这样的。有人知道怎么做吗?

2 个解决方案

#1


1  

You want to take a look at Smart App Banners.

你想看看智能应用的横幅。

#2


0  

The only way I know of to do this is to have the other app support a unique custom URL scheme. You can then ask the system if there are any apps installed that will respond to your custom scheme. If the answer is yes, you can be sure the other app is installed and ready to run.

我知道的唯一方法是让其他应用程序支持一个独特的自定义URL方案。然后,你可以询问系统是否安装了任何可以响应你的定制方案的应用程序。如果答案是肯定的,那么您可以确定其他应用程序已经安装好并准备运行。

#1


1  

You want to take a look at Smart App Banners.

你想看看智能应用的横幅。

#2


0  

The only way I know of to do this is to have the other app support a unique custom URL scheme. You can then ask the system if there are any apps installed that will respond to your custom scheme. If the answer is yes, you can be sure the other app is installed and ready to run.

我知道的唯一方法是让其他应用程序支持一个独特的自定义URL方案。然后,你可以询问系统是否安装了任何可以响应你的定制方案的应用程序。如果答案是肯定的,那么您可以确定其他应用程序已经安装好并准备运行。