Start app store from iPhone app

Source: Internet
Author: User

Http://blog.csdn.net/arthurchenjs/article/details/8447983

How can I start an app store from my own app? At the same time, how do I link to my own apps in the store?

-[UIApplication openURL:]Processes incoming links to applications and media.NSURLObject To start the corresponding Store application. Follow these steps to obtain the link: app, song, And album in iTunes, and link it to your iPhone app.

  1. Start iTunes on your computer

  2. Search for the project you want to add

  3. Right-click or control and click the project name in iTunes. In the displayed menu, choose Copy iTunes store URL"

  4. Use-[UIApplication openURL:]Open the modified URL string andNSURLObject.

Note: You can also use the iTunes link maker tool to obtain links to app songs or albums stored in ituns. See the iTunes link maker FAQ to learn more about the tool.

The following is an example of starting app store from a native application.

NSString *iTunesLink = @http://itunes.apple.com/us/app/id284417350?mt=8;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
 

There are some iTunes links, including iTunes-related links. Multiple redirects are returned before the links are linked to the corresponding application. You can useNsurlconnection silently processes these redirects and opens the final URL when the redirection is complete. This allows your applications to directly switch to the store without starting safari. The following shows how to complete this action.

NOTE: If your iTunes link is in uiwebview, you can use this method in-[UIWebViewDelegate webView:shouldStartLoadWithRequest:navigationType:]Intercept links in the entrusting method.

Process iTunes-related links on iPhone

// Process a LinkShare/TradeDoubler/DGM URL to something iPhone can handle
- (void)openReferralURL:(NSURL *)referralURL
{
    NSURLConnection *con = [[NSURLConnection alloc] initWithRequest:[NSURLRequest requestWithreferralURL]  delegate:self startImmediately:YES];
    [con release];
}
 
// Save the most recent URL in case multiple redirects occur
// "iTunesURL" is an NSURL property in your class declaration
- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response
{
    self.iTunesURL = [response URL];
    if( [self.iTunesURL.host hasSuffix:@"itunes.apple.com"])
    {
        [connection cancel];
        [self connectionDidFinishLoading:connection];
        return nil;
     }
     else
     {
       return request;
     }
}
 
// No more redirects; use the last URL saved
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    [[UIApplication sharedApplication] openself.iTunesURL];
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.