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
On this page, it says that I should “attempt to link to these URLs only if the user has the foursquare application installed”. I followed the link Foursquare gives but it seems to give specs for iOS app and not web pages.
Evidently, Safari doesn’t like at all when I try to open the “foursquare://” link without the app installed.
Is there a way to detect if the Foursquare App is installed ?
PS : my “code” looks like that :
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';
}
EDIT : This is kind of a duplicate of this question : Ajax call to check if native iPhone application exists on the device? – Thx @Jonathan Levison
I think you are asking for something like: Ajax call to check if native iPhone application exists on the device?
And it appears (from that question) that you cannot find out if the native app is installed via safari mobile web browser 🙁