简体   繁体   English

Android和Javascript:如何在javascript中了解是否已在Android设备中安装了应用程序?

[英]Android and Javascript: How to know in javascript that an application is installed in the Android device or not?

I have an android app on Google Play and also an website where. 我在Google Play上有一个android应用,还有一个网站。

For the moment, I am using javascript to detect if the device connected to the website is an android device. 目前,我正在使用javascript检测连接到网站的设备是否为android设备。 If is, I am displaying a popup dialog on the device inviting the user to download the app from the PlayStore. 如果是,我正在设备上显示一个弹出对话框,邀请用户从PlayStore下载该应用程序。 If the user clicks ok, he will be redirected to the PlayStore page of my app, I f he clicks no, he will continue using the browser. 如果用户单击确定,他将被重定向到我的应用程序的PlayStore页面,如果单击否,他将继续使用浏览器。

Now, the problem is that when the user have installed the app and tryes to access the webpage again, he will be asked again to download the app, even if he allready installed it (which is not a good idea). 现在,问题在于,当用户安装了该应用程序并尝试再次访问该网页时,即使他已经安装了该应用程序,也会再次要求他下载该应用程序(这不是一个好主意)。

Do you know a solution on how to check if the user has allready the app installed on his mobile device? 您是否知道如何检查用户是否已经在其移动设备上安装了该应用程序的解决方案?

It is also possible to do android detection with php, so if you have a method with php to detect if the app is installed, I can also use it. 也可以使用php进行android检测,因此,如果您有使用php的方法来检测应用程序是否已安装,我也可以使用它。

Thank you very much. 非常感谢你。

I don't think this is possible for security reasons. 我认为出于安全原因这是不可能的。 I would not want some random website I visit to be able to access my phone Package Manager and find out what apps I have installed. 我不想让我访问的任何随机网站都能访问我的手机“包裹管理器”,并找出我已安装的应用程序。

This would raise a lot of privacy and security concerns. 这将引起很多隐私和安全问题。

But I saw one answer that might have a different way of achieving your intent that might be useful to you: 但是我看到一个答案可能会以不同的方式实现您的意图,这可能对您有用:

https://stackoverflow.com/a/12901352/1369222 https://stackoverflow.com/a/12901352/1369222

Even if the user doesn't install your application, your web site shouldn't ask more than one or two times to download your application from the PlayStore. 即使用户没有安装您的应用程序,您的网站也不应多次要求从PlayStore下载您的应用程序。 The usual way of doing this is to use the browser's cookies in order to remember if it's a new visitor or not. 这样做的通常方法是使用浏览器的cookie,以记住它是否是新访问者。 It's not full proof because the cookies functionality could have been deactivated but at least, you won't have to worry about this problem for most of your visitors. 这不是充分的证据,因为cookie功能可以被停用,但是至少,您不必为大多数访问者担心此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM