Url scheme : Open app or Appstore from mail

ios, objective-c, url-scheme

Solution

`canOpenURL` is what you're looking for.

Here is an example for launching twitter app:

NSURL* twitterURL = [NSURL URLWithString:[NSString stringWithFormat:@"twitter:@%@", twitterUser]];

if ([[UIApplication sharedApplication] canOpenURL:twitterURL]) {
    [[UIApplication sharedApplication] openURL:twitterURL];
} else {
    NSURL* url = [NSURL URLWithString:@"http://itunes.apple.com/us/app/twitter/id333903271?mt=8"];
    [[UIApplication sharedApplication] openURL:url];
}   

EDIT

If you want do do this from a webpage or html email, you find your answer here: https://stackoverflow.com/a/627942/550177

and here: https://stackoverflow.com/a/1109200/550177

Problem

I'm creating an application where users can share data by sending emails to each other. In this mail there is a link to my app (I created an URL scheme for my app) But, if the users doesn't have my application on his iPhone, then when he clicks on the link, nothing happens. My question : How could I do to launch my app when the application is installed on the user's iPhone and launch the Appstore or a website if this application is not installed Thank you

Original source

Related problems