1

In my code, I need to determine if an app has been installed on the iphone device or not (the app I need to check is Square). If the app isn't installed, I would to open the app directly to Square, and if it is installed, I would like to open Square. Is there a way to do this? I checked out this discussion: iphone - Check if an app is installed , but wasn't able to work it out. Since I was not a developer of Square, where do I get the information about the URL scheme?

Thanks.

Community
  • 1
  • 1
coder
  • 10,460
  • 17
  • 72
  • 125

1 Answers1

4

It doesn't necessarily HAVE a scheme. The developers would have had to do that, and to have a reason to support incoming URLs. I don't know whether they've done that, or if they've documented it, or anything.

Assuming there's no documentation, then you can stab at it and see what you get. If you've got a guess at the scheme ("square:", perhaps?) you can test it with the canOpenUrl method of UIApplication:

UIApplication *app = [UIApplication sharedApplication];
if ([app canOpenURL:[NSURL URLWithString:@"square:"]]) {
    NSLog(@"found it!");
}

If "square:" is a URL scheme that any app on the device has declared, this code will tell you so in the console.

Dan Ray
  • 21,623
  • 6
  • 63
  • 87