zoukankan      html  css  js  c++  java
  • 如何从iPhone启动AppStore

    如何从IPhone启动AppStore

    Link Address: http://developer.apple.com/iphone/library/qa/qa2008/qa1629.html

    Technical Q&A QA1629Launching the App Store from an iPhone application

    Q: How do I launch the App Store from my iPhone application? Also, how do I link to my application on the store?
    A: The -[UIApplication openURL:] method handles links to applications and media by launching the appropriate store application 
    for the passed NSURL object. Follow the steps below to obtain a link to an application, song, or album sold on iTunes, 
    and link to it from your iPhone application.

    1. Launch iTunes on your Mac.

    2. Search for the item you want to link to.

    3. Right-click or control-click on the item's name in iTunes, then choose "Copy iTunes Store URL" from the pop-up menu.
    Note: The returned URL is an itunes.apple.com link. However, 
    iPhone requires phobosURLs for direct linking to the App Store. Therefore,
    you must replace itunes with phobosin the returned URL.


    4. Open the modified URL using an NSURL object and the -[UIApplication openURL] method.


    See Listing 1 for an example that launches the App Store from a native application.
    Listing 1: Launching the App Store from an iPhone application.

     
     
    NSString *iTunesLink = @"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=284417350&mt=8";
     
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
     



    If your application receives iTunes links at runtime—through an RSS feed generated fromhttp://itunes.apple.com/rss, for example—you can modify the URL with your code before opening it, as demonstrated in Listing 2.
    Listing 2: Refactoring an iTunes store link at runtime.

     
     
    NSString *iTunesLink = @"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=284417350&mt=8";
    NSURL *iTunesURL = [NSURL URLWithString:iTunesLink];
     
    // Produce a phobos.apple.com URL that will open the iTunes or App Store application directly
    [NSURL URLWithString:[NSString stringWithFormat:@"http://phobos.apple.com%@?%@",
     iTunesURL.path, iTunesURL.query]];
     


    Some iTunes links, including iTunes Affiliate links, result in multiple redirections before reaching the appropriate store application.
    You can process these redirects silently using NSURLConnection, and open the final URL once the redirects are complete.
    This allows your application to transition right to the store without launching Safari. 
    Listing 3 demonstrates how to accomplish this.

    Note: If you have iTunes links inside a UIWebView, 
    you can use this technique after intercepting the links with the 
    -[UIWebViewDelegate webView:shouldStartLoadWithRequest:navigationType:] delegate method.
    Listing 3: 

    Processing iTunes Affiliate links in an iPhone application.

     
     
    // Process a LinkShare/TradeDoubler/DGM URL to something iPhone can handle
    - (void)openReferralURL:(NSURL *)referralURL {
        NSURLConnection *conn = [[NSURLConnection alloc] 
    initWithRequest:[NSURLRequest requestWithURL:referralURL]
     delegate:self startImmediately:YES];
        [conn 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];
        return request;
    }
     
    // No more redirects; use the last URL saved
    - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
        [[UIApplication sharedApplication] openURL:self.iTunesLink];
    }
     


    THE END !
  • 相关阅读:
    高性能MySQL--创建高性能的索引
    error:0906D064:PEM routines:PEM_read_bio:bad base64 decode
    高性能MySQL--MySQL数据类型介绍和最优数据类型选择
    Elasticsearch入门和查询语法分析(ik中文分词)
    裁员浪潮,互联网人该何去何从?
    django+mysql的使用
    很详细的Django入门详解
    (2021年1月5日亲测有效)最新PyCharm 安装教程&激活破解,Pycharm激活,Pycharm破解
    (2021年1月5日更新)!最新的pycharm永久激活办法,亲测有效
    太干了!一张图整理了 Python 所有内置异常
  • 原文地址:https://www.cnblogs.com/xingchen/p/2104324.html
Copyright © 2011-2022 走看看