How to link to apps on the app store

Edited on 2016-02-02

Starting from iOS 6 SKStoreProductViewController class was introduced. You can link an app without leaving your app. Code snippet in Swift 3.x/2.x and Objective-C is here.

A SKStoreProductViewController object presents a store that allows the user to purchase other media from the App Store. For example, your app might display the store to allow the user to purchase another app.


From News and Announcement For Apple Developers.

Drive Customers Directly to Your App on the App Store with iTunes Links With iTunes links you can provide your customers with an easy way to access your apps on the App Store directly from your website or marketing campaigns. Creating an iTunes link is simple and can be made to direct customers to either a single app, all your apps, or to a specific app with your company name specified.

To send customers to a specific application: http://itunes.com/apps/appname

To send customers to a list of apps you have on the App Store: http://itunes.com/apps/developername

To send customers to a specific app with your company name included in the URL: http://itunes.com/apps/developername/appname


Additional notes:

You can replace http:// with itms:// or itms-apps:// to avoid redirects.

Please note that itms:// will send the user to the iTunes store and itms-apps:// with send them to the App Store!

For info on naming, see Apple QA1633:

https://developer.apple.com/library/content/qa/qa1633/_index.html.

Edit (as of January 2015):

itunes.com/apps links should be updated to appstore.com/apps. See QA1633 above, which has been updated. A new QA1629 suggests these steps and code for launching the store from an app:

  1. Launch iTunes on your computer.
  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.
  4. In your application, create an NSURL object with the copied iTunes URL, then pass this object to UIApplication' s openURL: method to open your item in the App Store.

Sample code:

NSString *iTunesLink = @"itms://itunes.apple.com/app/apple-store/id375380948?mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];

iOS10+:

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink] options:@{} completionHandler:nil];

Swift 4.2

   let urlStr = "itms-apps://itunes.apple.com/app/apple-store/id375380948?mt=8"
    if #available(iOS 10.0, *) {
        UIApplication.shared.open(URL(string: urlStr)!, options: [:], completionHandler: nil)
        
    } else {
        UIApplication.shared.openURL(URL(string: urlStr)!)
    }

If you want to open an app directly to the App Store, you should use:

itms-apps://...

This way it will directly open the App Store app in the device, instead of going to iTunes first, then only open the App Store (when using just itms://)

Hope that helps.


EDIT: APR, 2017. itms-apps:// actually works again in iOS10. I tested it.

EDIT: APR, 2013. This no longer works in iOS5 and above. Just use

https://itunes.apple.com/app/id378458261

and there are no more redirects.


Starting from iOS 6 right way to do it by using SKStoreProductViewController class.

Swift 5.x:

func openStoreProductWithiTunesItemIdentifier(_ identifier: String) {
    let storeViewController = SKStoreProductViewController()
    storeViewController.delegate = self

    let parameters = [ SKStoreProductParameterITunesItemIdentifier : identifier]
    storeViewController.loadProduct(withParameters: parameters) { [weak self] (loaded, error) -> Void in
        if loaded {
            // Parent class of self is UIViewContorller
            self?.present(storeViewController, animated: true, completion: nil)
        }
    }
}
private func productViewControllerDidFinish(viewController: SKStoreProductViewController) {
    viewController.dismiss(animated: true, completion: nil)
}
// Usage:
openStoreProductWithiTunesItemIdentifier("1234567")

Swift 3.x:

func openStoreProductWithiTunesItemIdentifier(identifier: String) {
    let storeViewController = SKStoreProductViewController()
    storeViewController.delegate = self

    let parameters = [ SKStoreProductParameterITunesItemIdentifier : identifier]
    storeViewController.loadProduct(withParameters: parameters) { [weak self] (loaded, error) -> Void in
        if loaded {
            // Parent class of self is UIViewContorller
            self?.present(storeViewController, animated: true, completion: nil)
        }
    }
}

func productViewControllerDidFinish(_ viewController: SKStoreProductViewController) {
    viewController.dismiss(animated: true, completion: nil)
}
// Usage:
openStoreProductWithiTunesItemIdentifier(identifier: "13432")

You can get the app's itunes item identifier like this: (instead of a static one)

Swift 3.2

var appID: String = infoDictionary["CFBundleIdentifier"]
var url = URL(string: "http://itunes.apple.com/lookup?bundleId=\(appID)")
var data = Data(contentsOf: url!)
var lookup = try? JSONSerialization.jsonObject(with: data!, options: []) as? [AnyHashable: Any]
var appITunesItemIdentifier = lookup["results"][0]["trackId"] as? String
openStoreProductViewController(withITunesItemIdentifier: Int(appITunesItemIdentifier!) ?? 0)

Swift 2.x:

func openStoreProductWithiTunesItemIdentifier(identifier: String) {
    let storeViewController = SKStoreProductViewController()
    storeViewController.delegate = self

    let parameters = [ SKStoreProductParameterITunesItemIdentifier : identifier]
    storeViewController.loadProductWithParameters(parameters) { [weak self] (loaded, error) -> Void in
        if loaded {
            // Parent class of self is UIViewContorller
            self?.presentViewController(storeViewController, animated: true, completion: nil)
        }
    }
}

func productViewControllerDidFinish(viewController: SKStoreProductViewController) {
    viewController.dismissViewControllerAnimated(true, completion: nil)
}
// Usage
openStoreProductWithiTunesItemIdentifier("2321354")

objective-C:

static NSInteger const kAppITunesItemIdentifier = 324684580;
[self openStoreProductViewControllerWithITunesItemIdentifier:kAppITunesItemIdentifier];

- (void)openStoreProductViewControllerWithITunesItemIdentifier:(NSInteger)iTunesItemIdentifier {
    SKStoreProductViewController *storeViewController = [[SKStoreProductViewController alloc] init];

    storeViewController.delegate = self;

    NSNumber *identifier = [NSNumber numberWithInteger:iTunesItemIdentifier];

    NSDictionary *parameters = @{ SKStoreProductParameterITunesItemIdentifier:identifier };
    UIViewController *viewController = self.window.rootViewController;
    [storeViewController loadProductWithParameters:parameters
                                   completionBlock:^(BOOL result, NSError *error) {
                                       if (result)
                                           [viewController presentViewController:storeViewController
                                                              animated:YES
                                                            completion:nil];
                                       else NSLog(@"SKStoreProductViewController: %@", error);
                                   }];

    [storeViewController release];
}

#pragma mark - SKStoreProductViewControllerDelegate

- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {
    [viewController dismissViewControllerAnimated:YES completion:nil];
}

You can get kAppITunesItemIdentifier (app's itunes item identifier) like this: (instead of a static one)

NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString* appID = infoDictionary[@"CFBundleIdentifier"];
    NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?bundleId=%@", appID]];
    NSData* data = [NSData dataWithContentsOfURL:url];
    NSDictionary* lookup = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
    NSString * appITunesItemIdentifier =  lookup[@"results"][0][@"trackId"]; 
    [self openStoreProductViewControllerWithITunesItemIdentifier:[appITunesItemIdentifier intValue]];