769

I am creating a free version of my iPhone game. I want to have a button inside the free version that takes people to the paid version in the app store. If I use a standard link

http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=300136119&mt=8

the iPhone opens Safari first, and then the app store. I have used other apps that open the app store directly, so I know it is possible.

Any ideas? What is the URL Scheme for the app store?

1

28 Answers 28

822

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)!)
    }
36
  • 164
    A tip is to use itms:// instead of http://, then it'll open in the app store directly. On the iPhone, it will make 2 (!) redirects when using http, and 1 when using itms. When using the older phobos links (see above), there are 0 redirects. Use the id from iTunes Connect if using phobos links. You can choose to submit an app without including the binary. This way you will get the id before you submit the actual binary. I haven't tried this, but I've heard it works.
    – quano
    Mar 14, 2010 at 1:59
  • 11
    See: developer.apple.com/library/ios/#qa/qa1633/_index.html (White space should just be removed.)
    – Nathan S.
    Apr 18, 2011 at 2:53
  • 10
    Except...what is the correct value to use for appname? Is it the app's "Bundle Display Name"? Is it case-insensitive? How are blank spaces handled, etc.?
    – aroth
    Sep 23, 2011 at 0:51
  • 16
    This should be tested on a real device.
    – Protocole
    Feb 7, 2012 at 9:31
  • 8
    This SHOULD be tested on a real device, yes! I struggled with nothing happening for about an hour before plugging the iPad in and testing it there. Geh.
    – Kalle
    Aug 16, 2012 at 18:42
373

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://)


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.

14
  • 2
    @PEZ As of today, I'm seeing two redirects when using http://... The answer works perfectly for me - itms-apps://... directly opens the App Store app on device, without any redirects.
    – Josh Brown
    Feb 3, 2011 at 7:20
  • 4
    Rocotilos, are you sure this no longer works? Can you post a link?
    – johndodo
    May 19, 2013 at 17:33
  • 9
    On iOS. itms opens itunes. while itms-apps opens the App Store. This is a key difference if prompting users to update! (iOS 10)
    – mcm
    Dec 16, 2016 at 22:40
  • 2
    itms-apps opens the App Store app for me via openURL: in iOS 10.2. Seems to be no issue.
    – pkamb
    Mar 3, 2017 at 23:06
  • 1
    Since 10.3 this method works but it have to pass through an intermediate display popup 'open this URL with app store'? Reference: blog.branch.io/…
    – gabry
    Jul 20, 2017 at 14:48
63

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]];
4
  • 4
    in swift don't forget to import and delegate: import StoreKit class RateMeViewController: UIViewController, SKStoreProductViewControllerDelegate {
    – djdance
    Apr 11, 2016 at 21:45
  • This still works, however when you go and click Write a Review, it does not work. You have to click the Store button in the top corner and then click Write a Review. Anyone know a workaround??
    – socca1157
    May 21, 2016 at 18:59
  • "Write a review" tries to open another modal and fails, probably because you're already presenting in modal. But Apple forces it. So seems there is no proper way to make reviews work. rendering this whole concept void.
    – AmitP
    Jan 23, 2017 at 14:41
  • That json not always returning data and returns count zero sometimes. Not reliable to get app id before submission.
    – Amber K
    Feb 4, 2019 at 13:06
43

Apple just announced the appstore.com urls.

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

There are three types of App Store Short Links, in two forms, one for iOS apps, another for Mac Apps:

Company Name

iOS: http://appstore.com/ for example, http://appstore.com/apple

Mac: http://appstore.com/mac/ for example, http://appstore.com/mac/apple

App Name

iOS: http://appstore.com/ for example, http://appstore.com/keynote

Mac: http://appstore.com/mac/ for example, http://appstore.com/mac/keynote

App by Company

iOS: http://appstore.com// for example, http://appstore.com/apple/keynote

Mac: http://appstore.com/mac// for example, http://appstore.com/mac/apple/keynote

Most companies and apps have a canonical App Store Short Link. This canonical URL is created by changing or removing certain characters (many of which are illegal or have special meaning in a URL (for example, "&")).

To create an App Store Short Link, apply the following rules to your company or app name:

Remove all whitespace

Convert all characters to lower-case

Remove all copyright (©), trademark (™) and registered mark (®) symbols

Replace ampersands ("&") with "and"

Remove most punctuation (See Listing 2 for the set)

Replace accented and other "decorated" characters (ü, å, etc.) with their elemental character (u, a, etc.)

Leave all other characters as-is.

Listing 2 Punctuation characters that must be removed.

!¡"#$%'()*+,-./:;<=>¿?@[]^_`{|}~

Below are some examples to demonstrate the conversion that takes place.

App Store

Company Name examples

Gameloft => http://appstore.com/gameloft

Activision Publishing, Inc. => http://appstore.com/activisionpublishinginc

Chen's Photography & Software => http://appstore.com/chensphotographyandsoftware

App Name examples

Ocarina => http://appstore.com/ocarina

Where’s My Perry? => http://appstore.com/wheresmyperry

Brain Challenge™ => http://appstore.com/brainchallenge

3
  • 1
    this is actually the only thing that still works reliable for mac store at least Oct 19, 2015 at 0:05
  • Good to know about this, but unfortunately on iOS this redirects through Safari (and gives an ugly "Cannot Verify Server Identity" message). Jan 15, 2016 at 22:52
  • NO. Read this - "These App Store Short Links are provided as a convenience and are not guaranteed to link to a particular app or company." So basically it is randomly given.
    – durazno
    Sep 27, 2016 at 7:20
42

For summer 2015 onwards ...

-(IBAction)clickedUpdate
{
    NSString *simple = @"itms-apps://itunes.apple.com/app/id1234567890";
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:simple]];
}

replace 'id1234567890' with 'id' and 'your ten digit number'

  1. This works perfectly on all devices.

  2. It does go straight to the app store, no redirects.

  3. Is OK for all national stores.

  4. It's true you should move to using loadProductWithParameters, but if the purpose of the link is to update the app you are actually inside of: it's possibly better to use this "old-fashioned" approach.

3
  • Also, for directing to your developer page (if you want to show the user your catalogue of apps) you can use: NSString *simple = @"itms-apps://itunes.com/apps/YOUR_COMPANY_NAME"; Aug 18, 2015 at 9:49
  • 3
    Where do I find this id ?
    – mcfly soft
    Mar 18, 2016 at 11:31
  • 3
    Summer 2015?! Like the entire world lives in the same country. :(
    – nacho4d
    Sep 11, 2018 at 2:31
38

To have a direct link without redirection :

  1. Use Apple Services Marketing Tools : https://tools.applemediaservices.com/ to get the real direct link
  2. Replace the https:// with itms-apps://
  3. Open the link with UIApplication.shared.open(url, options: [:])

Be careful, those links only works on actual devices, not in simulator.

Source :

3
  • 5
    +1 for itunes.apple.com/linkmaker,everyone test the link in device not in simulator, I was wasting time in testing simulator.
    – karthik
    Sep 3, 2013 at 10:43
  • 3
    Thanks for info about Simulator, I'll add this to the answer
    – Dulgan
    Sep 3, 2013 at 14:39
  • 1
    this is now https://tools.applemediaservices.com/app-store/
    – rwcorbett
    Mar 16, 2022 at 20:51
32

This code generates the App Store link on iOS

NSString *appName = [NSString stringWithString:[[[NSBundle mainBundle] infoDictionary]   objectForKey:@"CFBundleName"]];
NSURL *appStoreURL = [NSURL URLWithString:[NSString stringWithFormat:@"itms-apps://itunes.com/app/%@",[appName stringByReplacingOccurrencesOfString:@" " withString:@""]]];

Replace itms-apps with http on Mac:

NSURL *appStoreURL = [NSURL URLWithString:[NSString stringWithFormat:@"http:/itunes.com/app/%@",[appName stringByReplacingOccurrencesOfString:@" " withString:@""]]]; 

Open URL on iOS:

[[UIApplication sharedApplication] openURL:appStoreURL];

Mac:

[[NSWorkspace sharedWorkspace] openURL:appStoreURL];
3
  • This works, but you also have to remove special characters like dashes from the app name. Apr 30, 2012 at 17:27
  • Can we open and show all the apps uploaded by the developer in one page?
    – Imran
    Mar 12, 2014 at 10:56
  • This was the only drop-in solution that worked for me with minimum redirects and maximum handling of app name whitespace. Apr 22, 2015 at 15:42
30

Simply change 'itunes' to 'phobos' in the app link.

http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=300136119&mt=8

Now it will open the App Store directly

0
20

This worked for me perfectly using only APP ID:

 NSString *urlString = [NSString stringWithFormat:@"http://itunes.apple.com/app/id%@",YOUR_APP_ID];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];

The number of redirects is ZERO.

0
14

A number of answers suggest using 'itms' or 'itms-apps' but this practice is not specifically recommended by Apple. They only offer the following way to open the App Store:

Listing 1 Launching the App Store from an iOS application

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

See https://developer.apple.com/library/ios/qa/qa1629/_index.html last updated March, 2014 as of this answer.

For apps that support iOS 6 and above, Apple offers a in-app mechanism for presenting the App Store: SKStoreProductViewController

- (void)loadProductWithParameters:(NSDictionary *)parameters completionBlock:(void (^)(BOOL result, NSError *error))block;

// Example:
SKStoreProductViewController* spvc = [[SKStoreProductViewController alloc] init];
spvc.delegate = self;
[spvc loadProductWithParameters:@{ SKStoreProductParameterITunesItemIdentifier : @(364709193) } completionBlock:^(BOOL result, NSError *error){ 
    if (error)
        // Show sorry
    else
        // Present spvc
}];

Note that on iOS6, the completion block may not be called if there are errors. This appears to be a bug that was resolved in iOS 7.

13

If you want to link to a developer's apps and the developer's name has punctuation or spaces (e.g. Development Company, LLC) form your URL like this:

itms-apps://itunes.com/apps/DevelopmentCompanyLLC

Otherwise it returns "This request cannot be processed" on iOS 4.3.3

3
  • 1
    If this doesn't work for you, try the following syntax: itms-apps://itunes.com/apps/ChuckSmith/id290402113 replacing my name with your company and my ID with your Artist ID which you can get from the iTunes link maker: itunes.apple.com/linkmaker Jan 10, 2012 at 12:40
  • You could also try to encode those "special" chars - i.e. replace "." with "%2E"
    – wzs
    Mar 7, 2012 at 8:50
  • that is THE prefect answer!
    – Sam B
    Mar 1, 2013 at 23:50
13

You can get a link to a specific item in the app store or iTunes through the link maker at: http://itunes.apple.com/linkmaker/

1
  • This one help me, because the link in my itunes-connect didn't work, and in the generator it does. thank you
    – Dorad
    Nov 6, 2015 at 12:10
9

This is working and directly linking in ios5

NSString *iTunesLink = @"http://itunes.apple.com/app/baseball-stats-tracker-touch/id490256272?mt=8";  
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
9

All the answers are outdated and don't work; use the below method.

All apps of a developer:
itms-apps://apps.apple.com/developer/developer-name/developerId

Single app:
itms-apps://itunes.apple.com/app/appId

8

This is simple and short way to redirect/link other existing application on app store.

 NSString *customURL = @"http://itunes.apple.com/app/id951386316";

 if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:customURL]])
 {
       [[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURL]];
 } 
7

For Xcode 9.1 and Swift 4:

  1. Import StoreKit:
import StoreKit

2.Conform the protocol

SKStoreProductViewControllerDelegate

3.Implement the protocol

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)
        }
    }   
}

3.1

func productViewControllerDidFinish(_ viewController: SKStoreProductViewController) {
    viewController.dismiss(animated: true, completion: nil)
}
  1. How to use:
openStoreProductWithiTunesItemIdentifier(identifier: "here_put_your_App_id")

Note:

It is very important to enter the exact ID of your APP. Because this cause error (not show the error log, but nothing works fine because of this)

1
  • 1
    I am doing the same thing, running on the device. No success
    – mugx
    Dec 20, 2017 at 2:24
6

I can confirm that if you create an app in iTunes connect you get your app id before you submit it.

Therefore..

itms-apps://itunes.apple.com/app/id123456789

NSURL *appStoreURL = [NSURL URLWithString:@"itms-apps://itunes.apple.com/app/id123456789"];
    if ([[UIApplication sharedApplication]canOpenURL:appStoreURL])
        [[UIApplication sharedApplication]openURL:appStoreURL];

Works a treat

5

I think Apple has provided a new link for the app link: https://apps.apple.com/app/id1445530088 or https://apps.apple.com/app/ {your_app_id}

2
4

Creating a link could become a complex issue when supporting multiple OS and multiple platform. For example the WebObjects isn't supported on iOS 7 (some of them), some links you create would open another country store then the user's etc.

There is an open source library called iLink that could help you.

There advantages of this library is that the links would be found and created at run time (the library would check the app ID and the OS it is running on and would figure out what link should be created). The best point in this is that you don't need to configure almost anything before using it so that is error free and would work always. That's great also if you have few targets on same project so you don't have to remember which app ID or link to use. This library also would prompt the user to upgrade the app if there is a new version on the store (this is built in and you turn this off by a simple flag) directly pointing to the upgrade page for the app if user agrees.

Copy the 2 library files to your project (iLink.h & iLink.m).

On your appDelegate.m:

#import "iLink.h"

+ (void)initialize
{
    //configure iLink
    [iLink sharedInstance].globalPromptForUpdate = YES; // If you want iLink to prompt user to update when the app is old.
}

and on the place you want to open the rating page for example just use:

[[iLink sharedInstance] iLinkOpenAppPageInAppStoreWithAppleID: YOUR_PAID_APP_APPLE_ID]; // You should find YOUR_PAID_APP_APPLE_ID from iTunes Connect 

Don't forget to import iLink.h on the same file.

There is a very good doc for the whole library there and an example projects for iPhone and for Mac.

4

At least iOS 9 and above

  • Open directly in the App Store

An app

itms-apps://itunes.apple.com/app/[appName]/[appID]

List of developer's apps

itms-apps://itunes.apple.com/developer/[developerName]/[developerID]
1
  • appName is not necessary.
    – DawnSong
    Nov 21, 2019 at 5:11
4

According to Apple's latest document You need to use

appStoreLink = "https://itunes.apple.com/us/app/apple-store/id375380948?mt=8"  

or

SKStoreProductViewController 
2
  • Can you update your link please? This seems quite interesting if that won't work. Jun 7, 2018 at 2:58
  • The linked document doesn't mention itms: or itms-apps:. Links using that scheme work fine on my devices running iOS 12.
    – Theo
    Nov 13, 2018 at 10:57
4

Despite there being loads of answers here, none of the suggestions for linking to the developers apps seem to work anymore.

When I last visited I was able to get it working using the format:

itms-apps://itunes.apple.com/developer/developer-name/id123456789

This no longer works, but removing the developer name does:

itms-apps://itunes.apple.com/developer/id123456789
3

If you have the app store id you are best off using it. Especially if you in the future might change the name of the application.

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

If you don't have tha app store id you can create an url based on this documentation https://developer.apple.com/library/ios/qa/qa1633/_index.html

+ (NSURL *)appStoreURL
{
    static NSURL *appStoreURL;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        appStoreURL = [self appStoreURLFromBundleName:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]];
    });
    return appStoreURL;
}

+ (NSURL *)appStoreURLFromBundleName:(NSString *)bundleName
{
    NSURL *appStoreURL = [NSURL URLWithString:[NSString stringWithFormat:@"itms-apps://itunes.com/app/%@", [self sanitizeAppStoreResourceSpecifier:bundleName]]];
    return appStoreURL;
}

+ (NSString *)sanitizeAppStoreResourceSpecifier:(NSString *)resourceSpecifier
{
    /*
     https://developer.apple.com/library/ios/qa/qa1633/_index.html
     To create an App Store Short Link, apply the following rules to your company or app name:

     Remove all whitespace
     Convert all characters to lower-case
     Remove all copyright (©), trademark (™) and registered mark (®) symbols
     Replace ampersands ("&") with "and"
     Remove most punctuation (See Listing 2 for the set)
     Replace accented and other "decorated" characters (ü, å, etc.) with their elemental character (u, a, etc.)
     Leave all other characters as-is.
     */
    resourceSpecifier = [resourceSpecifier stringByReplacingOccurrencesOfString:@"&" withString:@"and"];
    resourceSpecifier = [[NSString alloc] initWithData:[resourceSpecifier dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES] encoding:NSASCIIStringEncoding];
    resourceSpecifier = [resourceSpecifier stringByReplacingOccurrencesOfString:@"[!¡\"#$%'()*+,-./:;<=>¿?@\\[\\]\\^_`{|}~\\s\\t\\n]" withString:@"" options:NSRegularExpressionSearch range:NSMakeRange(0, resourceSpecifier.length)];
    resourceSpecifier = [resourceSpecifier lowercaseString];
    return resourceSpecifier;
}

Passes this test

- (void)testAppStoreURLFromBundleName
{
    STAssertEqualObjects([AGApplicationHelper appStoreURLFromBundleName:@"Nuclear™"].absoluteString, @"itms-apps://itunes.com/app/nuclear", nil);
    STAssertEqualObjects([AGApplicationHelper appStoreURLFromBundleName:@"Magazine+"].absoluteString, @"itms-apps://itunes.com/app/magazine", nil);
    STAssertEqualObjects([AGApplicationHelper appStoreURLFromBundleName:@"Karl & CO"].absoluteString, @"itms-apps://itunes.com/app/karlandco", nil);
    STAssertEqualObjects([AGApplicationHelper appStoreURLFromBundleName:@"[Fluppy fuck]"].absoluteString, @"itms-apps://itunes.com/app/fluppyfuck", nil);
    STAssertEqualObjects([AGApplicationHelper appStoreURLFromBundleName:@"Pollos Hérmanos"].absoluteString, @"itms-apps://itunes.com/app/polloshermanos", nil);
    STAssertEqualObjects([AGApplicationHelper appStoreURLFromBundleName:@"Niños and niñas"].absoluteString, @"itms-apps://itunes.com/app/ninosandninas", nil);
    STAssertEqualObjects([AGApplicationHelper appStoreURLFromBundleName:@"Trond, MobizMag"].absoluteString, @"itms-apps://itunes.com/app/trondmobizmag", nil);
    STAssertEqualObjects([AGApplicationHelper appStoreURLFromBundleName:@"!__SPECIAL-PLIZES__!"].absoluteString, @"itms-apps://itunes.com/app/specialplizes", nil);
}
3

Most of the solutions here are outdated & deprecated

For those looking for the updated working solution

// let appStoreLink = "https://apps.apple.com/app/{app-name}/{app-id}"

guard let url = URL(string: Constants.App.appStoreLink) else { return }
UIApplication.shared.open(url)
1
  • 1
    This seems to work for me in 2023. It seems all the previous methods that did not also include the app-id no longer work. Using the itms-apps://apps.apple.com/app/{app-name}/{app-id} suffix on a Mac also works, and might be one less load in the browser.
    – mobob
    Mar 14, 2023 at 10:02
1

it will open the App Store directly

NSString *iTunesLink = @"itms-apps://itunes.apple.com/app/ebl- 
skybanking/id1171655193?mt=8";

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
0

Try this way

http://itunes.apple.com/lookup?id="your app ID here" return json.From this, find key "trackViewUrl" and value is the desired url. use this url(just replace https:// with itms-apps://).This works just fine.

For example if your app ID is xyz then go to this link http://itunes.apple.com/lookup?id=xyz

Then find the url for key "trackViewUrl".This is the url for your app in app store and to use this url in xcode try this

NSString *iTunesLink = @"itms-apps://itunes.apple.com/us/app/Your app name/id Your app ID?mt=8&uo=4";
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];

Thanks

0

in SwiftUI - IOS 15.0

//
//  Test.swift
//  PharmaCodex
//

import SwiftUI

struct Test: View {
    
    var body: some View {
        
        VStack {
            
            Button(action: {
                guard let writeReviewURL = URL(string: "https://apps.apple.com/app/id1629135515?action=write-review") else {
                    fatalError("Expected a valid URL")
                }
                UIApplication.shared.open(writeReviewURL, options: [:], completionHandler: nil)
                
            }) {
                Text("Rate/Review")
            }
            
            
        }
    }
}

struct Test_Previews: PreviewProvider {
    static var previews: some View {
        Test()
    }
}
0

For me (in 2023) itms-apps:// doesn't work but itms-appss:// does!

itms-appss://apps.apple.com/app/idYOUR_ID_HERE

I suspect Apple added the extra s because they don't want us using it any more but there are some edge cases where it's still extremely helpful.

For 99% of cases you'll want to use the regular link:

https://apps.apple.com/us/app/wavelength/idYOUR_ID_HERE

Not the answer you're looking for? Browse other questions tagged or ask your own question.