如何通过Safari Mobile中的javascript检测我的iPhone应用程序是否已安装? [英] How do I detect, via javascript in Safari Mobile, if my iPhone application is installed?
问题描述
您可能知道,iPhone应用程序可以注册自定义URL方案处理程序,alamyapp:,这些可以用于在Safari中查看的页面中的链接。
As you probably know, iPhone applications can register a custom URL scheme handler, ala "myapp:" and these can be used for links in a page viewed in Safari.
如果访问者安装了应用程序,我想从特定页面自动启动我的应用程序。如果该应用未安装,我只会向他们展示当前针对该页面的移动设备优化视图。
I'd like to automatically launch my application from a specific page if the visitor has the app installed. If the app's not installed, I'll just show them the current mobile-optimized view of the page.
如何进行此检测?谷歌的搜索毫无结果。另外,为了变得棘手,我尝试过这样的事情无济于事:
How can I do this detection? Google searches have been fruitless. Also, to be tricky, I've tried doing something like this to no avail:
var image = new Image();
image.onerror = function(e){
alert("bummer");
}
image.onload = function(e){
alert('success!');
}
image.src = 'myapp://something=meaningful';
有没有人遇到过检测应用程序的方法?
Has anyone come across a way to do application detection?
推荐答案
解决方案我在另一个Stack Overflow问题上提出的问题与你将要获得的一样接近。
The solution I've presented on another Stack Overflow question is about as close as you're going to get.
这篇关于如何通过Safari Mobile中的javascript检测我的iPhone应用程序是否已安装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!