Check if iphone has Square app installed - open or install
In my code, I need to determine if an app has been installed on the iphone d开发者_StackOverflow社区evice 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.
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.
精彩评论