【发布时间】:2012-02-06 22:01:49
【问题描述】:
我正在使用 Foursquare API 开发一个有趣的小项目。在这个项目中,我有一个 PHP/HTML 页面,可以将用户重定向到foursquare 应用程序。作为我们应该使用“很好地降级”的方法,Android 没有明显的问题。
在我的 HTML 页面中,我使用 javascript 来检测用户正在使用哪部手机。如果它检测到 iOS,页面会使用类似“foursquare://users/USER_ID”的 URL 重定向到 Foursquare 应用程序:https://developer.foursquare.com/resources/client
在这个页面上,它说我应该“只有在用户安装了foursquare 应用程序时才尝试链接到这些URL”。我关注了 Foursquare 给出的链接,但它似乎给出了 iOS 应用程序而不是网页的规格。
显然,当我尝试在未安装应用程序的情况下打开“foursquare://”链接时,Safari 根本不喜欢。
有没有办法检测是否安装了 Foursquare 应用程序?
PS:我的“代码”看起来像这样:
if(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i)){
location.href='foursquare://venues/VENUE_ID';
}else{
location.href='http://m.foursquare.com/venue/VENUE_ID';
}
编辑:这是这个问题的重复:Ajax call to check if native iPhone application exists on the device? - Thx @Jonathan Levison
【问题讨论】:
标签: javascript api web-applications foursquare