【问题标题】:Foursquare API : check if users have the iphone app before redirecting themFoursquare API:在重定向用户之前检查用户是否有 iphone 应用程序
【发布时间】: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


    【解决方案1】:

    我认为您要求的是:Ajax call to check if native iPhone application exists on the device?

    而且(从那个问题)看来,您无法确定本机应用程序是否是通过 safari 移动网络浏览器安装的:(

    【讨论】:

    • 看来我真的不走运!感谢您提供我没有找到的链接;)
    猜你喜欢
    • 2022-11-17
    • 2019-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-27
    • 2020-07-18
    • 2018-04-16
    • 2011-01-19
    相关资源
    最近更新 更多