Question

I'm making an app that shows you the list of all apps you have installed, then when I select then, I want to launch that app in my device. I'm using the following code

- (IBAction)openapp:(NSString*)app
{
    urlString =  [[NSString alloc]initWithFormat:@"%@:",app.accessibilityLabel];//init string with app name and append it to ":"

    [urlString stringByReplacingOccurrencesOfString:@" "withString:@""];//remove all spaces

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];//open URL with scheme
}

It work in some cases that the scheme is the same as the name of the app, but sometimes it fails because it isn't (example - facebook scheme = fb). So, I need to get the scheme of the app from somewhere. Also I can't just create a NSString and alloc a fixed scheme there because the app I'll be opening will change from device to device. Anyone can help me with that?

Was it helpful?

Solution

I don't think it's possible due to the sandbox nature of apps meaning that the required information isn't readable. I can't find reference to any Apple collated list either.

This quote from the Apple Docs, though not conclusive, implies that it's not possible since it's not even possible to determine which app, if any, will open.

**Note: If more than one third-party app registers to handle the same URL scheme, there is currently no process for determining which app will be given that scheme.


If you already know which apps you want to check are installed, this method should return YES:

[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"myScheme://"] 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top