Friday, 17 July 2020

How to link to apps on the app store

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?


Answers:


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


Answers:


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]];

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

Answers:


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.


Answers:


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


Answers:


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]];

Answers:


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];

Answers:


To have a direct link without redirection :

  1. Use iTunes link maker http://itunes.apple.com/linkmaker/ to get the real direct link
  2. Replace the http:// with itms-apps://
  3. Open the link with [[UIApplication sharedApplication] openURL:url];

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

Source : https://developer.apple.com/library/ios/#qa/qa2008/qa1629.html


Answers:


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.


Answers:


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/


Answers:


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


Answers:


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


Answers:


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


Answers:


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

Answers:


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.


Answers:


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.


Answers:


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]];
 } 

Answers:


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]];

Answers:


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.


Answers:


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]

Answers:


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)


Answers:


According to Apple's latest document You need to use

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

or

SKStoreProductViewController 

Answers:


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

Answers:


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]];

Answers:


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


Answers:


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}


Answers:


No comments:

Post a Comment