0

Instagram has some cool hooks that can be used to open the app from a web url.

e.g. instagram://camera

But when a user doesn't have instagram installed, the browser doesn't know how to handle the url. Is there a way for me to detect if the user has instagram installed (in javascript)?

posit labs
  • 8,951
  • 4
  • 36
  • 66

2 Answers2

3

In Objective-C the [[UIApplication sharedApplication] canOpenURL:url] expression may be used to detect whether a URL is handled by any app in the system. If you use PhoneGap or some similar framework, then look for this method. If you have only a webapp, then I'm pretty sure that this is impossible.

The issue with a web app is that it is sandboxed like a web page, it cannot reach outside of the browser. However, it seems to be possible that you can detect the presence with a timing based method. That is, if the app is not installed, the user will return to, or not be able to leave at all the browser within a certain, relatively short time. Thinking along these lines I found this solution: Check if URL scheme is supported in javascript

You may be able to build a solution using this approach, but the "Cannot Open Page" alert box will always be thrown at your users. Though, this IMHO is not really annoying if you handle it correctly on the web app side.

Community
  • 1
  • 1
allprog
  • 16,540
  • 9
  • 56
  • 97
0

UIApplication has a method canOpenURL: that you can use to check.

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"instagram://camera"]]) {

}
Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281