I'm developing a fun little project using Foursquare API. In this project, I have a PHP/HTML page that redirects users to the foursquare app. There is no apparent issue with Android as the method we ought to use "degrade nicely".
In my HTML page, I use JavaScript to detect which phone the user is using. If it detects iOS, the page redirect to the Foursquare App using a URL like this "foursquare://users/USER_ID" found here : https://developer.foursquare.com/resources/client
このページでは、「四角形のアプリケーションがインストールされている場合にのみ、これらのURLにリンクしてください」と言います。私はFoursquareのリンクをたどったが、iOSアプリの仕様ではなく、Webページの仕様を与えるようだ。
明らかに、Safariは、アプリがインストールされていない状態で「foursquare://」リンクを開こうとすると、まったく気に入らない。
Is there a way to detect if the Foursquare App is installed ?
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';
}
編集:これは、この質問の重複のようです:ネイティブiPhoneアプリケーションがデバイスに存在するかどうかを確認するAjaxコール? - Thx @Jonathan Levison