Skip to content Skip to sidebar Skip to footer

Shared Link That Will Open My App Or The App Store

I have started working on an iPhone app and I decided I want the user to be able to share things from it on the web (through email, Facebook, twitter, messages and so on...). Now I

Solution 1:

- (IBAction)openOtherAppButtonAction
{
    UIApplication *ourApplication = [UIApplication sharedApplication];
    NSString *URLEncodedText = [@"AppName" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSString *ourPath = [@"openapp://" stringByAppendingString:URLEncodedText];   //openapp is the url custom scheme name.
    NSURL *ourURL = [NSURL URLWithString:ourPath];                              //instead of our path you can directly write @"openapp"

     if ([ourApplication canOpenURL:ourURL]) 
         [ourApplication openURL:ourURL];
    else 
    {
        //Display error
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Receiver Not Found" message:@"The Receiver App is not installed." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alertView show];
 // OR open link
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"www.urlForApp.com"]];
    }
}

// Now which app you want to open go its info.plist

1 Add a new row with name ----> URL types

2 Now in Item 0 add another object named ------> URL Schemes

3 Now at Item 0 of URL Schemes give the name through which you want to open your app for e.g @"openapp"

4 You have to write this in app delegate of the app you want to open

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url    {    return YES;    }

Post a Comment for "Shared Link That Will Open My App Or The App Store"