我正在创造自己的iPhone游戏的免费版本。我想在免费版本中添加一个按钮,引导用户进入应用商店中的付费版本。如果我使用标准链接

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

iPhone首先打开Safari,然后打开应用商店。我使用过其他直接打开应用程序商店的应用程序,所以我知道这是可能的。

什么好主意吗?应用商店的URL方案是什么?


只需在应用程序链接中将“itunes”改为“phobos”即可。

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

现在它会直接打开应用商店


编辑于2016-02-02

从ios6开始,SKStoreProductViewController类被引入。你可以在不离开你的应用程序的情况下链接一个应用程序。x和Objective-C在这里。

SKStoreProductViewController对象表示一个存储,该存储允许 用户可以从应用商店购买其他媒体。例如,你的应用程序 可能会显示商店以允许用户购买另一款应用。


来自苹果开发者的新闻和公告。

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


其他说明:

为了避免重定向,可以将http://替换为itms://或itms-apps://。

请注意,itms://会将用户发送到iTunes商店,itms-apps://会将用户发送到App store !

有关命名的信息,请参见Apple QA1633:

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

编辑(截至2015年1月):

Itunes.com/apps链接应更新为appstore.com/apps。见上文QA1633,已更新。新的QA1629建议从应用程序启动商店的步骤和代码:

在你的电脑上启动iTunes。 搜索要链接的项目。 在iTunes中右键单击或控制单击项目名称,然后从弹出菜单中选择“复制iTunes Store URL”。 在你的应用中,用复制的iTunes URL创建一个NSURL对象,然后将这个对象传递给UIApplication的openURL:方法来在App Store中打开你的项目。

示例代码:

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

斯威夫特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)!)
    }

如果你想直接在app Store中打开应用,你应该使用:

itms-apps: / /……

这样,它将直接打开设备中的App Store应用程序,而不是先去iTunes,然后只打开App Store(当只使用itms://)


编辑时间:2017年4月。 itms-apps://实际上在iOS10中再次工作。我测试过了。

编辑:2013年4月。 这在iOS5及以上版本中不再适用。只使用

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

也没有更多的重定向。


如果你想链接到开发商的应用,而开发商的名字中有标点符号或空格(例如Development Company, LLC),你的URL是这样的:

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

否则它在iOS 4.3.3上返回“此请求不能被处理”


这是工作和直接链接在ios5

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

这段代码生成iOS上的App Store链接

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

在Mac上用http替换itms-apps:

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

在iOS上打开URL:

[[UIApplication sharedApplication] openURL:appStoreURL];

Mac:

[[NSWorkspace sharedWorkspace] openURL:appStoreURL];

直接链接:没有重定向而有直接链接:

使用苹果服务营销工具:https://tools.applemediaservices.com/获得真正的直接链接 将https://替换为itms-apps:// 用UIApplication.shared打开链接。打开(url,选项:[:])

注意,这些链接只在实际设备上工作,而不是在模拟器中。

来源:

评论:新的链接归功于@rwcorbett 苹果文档:https://developer.apple.com/library/ios/#qa/qa2008/qa1629.html


这对我来说非常有效,只使用APP ID:

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

重定向的数量为0。


你可以通过以下链接生成器获得应用商店或iTunes中特定项目的链接: http://itunes.apple.com/linkmaker/


苹果刚刚公布了appstore.com的网址。

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


试试这个方法

http://itunes.apple.com/lookup?id=“你的应用ID在这里”返回json。从这里,找到键“trackViewUrl”和值是所需的url。使用这个url(只需将https://替换为itms-apps://)。这工作得很好。

例如,如果你的应用ID是xyz,那么就转到这个链接 http://itunes.apple.com/lookup?id=xyz

然后找到“trackViewUrl”键的url。这是你的应用程序在应用商店的url,在xcode中使用这个url试试这个

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

谢谢


我可以确认,如果你在iTunes connect上创建应用,你会在提交应用之前获得应用id。

因此. .

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

工作是一种享受


如果你有应用商店id,你最好使用它。特别是当您将来可能更改应用程序的名称时。

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

如果你没有应用商店id,你可以根据这个文档创建一个url 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;
}

通过测试

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

许多答案建议使用“itms”或“itms-apps”,但苹果并没有特别推荐这种做法。他们只提供以下方式打开App Store:

清单1从iOS应用程序启动App Store

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

参见https://developer.apple.com/library/ios/qa/qa1629/_index.html, 2014年3月更新。

对于支持iOS 6及以上版本的应用程序,苹果提供了一种应用内机制来呈现应用程序商店: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
}];

注意,在iOS6上,如果有错误,completion块可能不会被调用。这似乎是一个在iOS 7中解决的错误。


当支持多个操作系统和平台时,创建链接可能会成为一个复杂的问题。例如,在iOS 7上不支持WebObjects(其中一些),你创建的一些链接会打开另一个国家的商店,然后用户的等等。

有一个叫做iLink的开源库可以帮助你。

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.

复制两个库文件到你的项目(iLink.h & iLink.m)。

在你的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.
}

例如,在你想打开评级页面的地方,只需使用:

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

不要忘记在同一个文件中导入iLink.h。

这里有一个很好的整个库的文档还有一个iPhone和Mac的示例项目。


这是重定向/链接应用商店中其他现有应用程序的简单而简短的方法。

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

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

从ios6开始正确的方法是使用SKStoreProductViewController类。

斯威夫特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")

斯威夫特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")

你可以像这样获得应用的itunes项目标识符(而不是一个静态标识符):

斯威夫特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)

斯威夫特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];
}

你可以像这样获得kAppITunesItemIdentifier(应用的itunes项目标识符):(而不是一个静态的)

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

2015年夏天开始……

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

将'id1234567890'替换为'id'和'您的十位数'

这在所有设备上都能完美地工作。 它会直接进入应用商店,没有重定向。 对全国所有商店都是可以的。 的确,你应该转而使用loadProductWithParameters,但如果链接的目的是更新你实际所在的应用程序:使用这种“老式”方法可能更好。


至少iOS 9及以上版本

直接在App Store打开

一个应用程序

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

开发者的应用程序列表

itms-apps://itunes.apple.com/developer/[developerName]/[developerID]

对于Xcode 9.1和Swift 4:

进口StoreKit:

进口StoreKit

2.遵守协议

SKStoreProductViewControllerDelegate

3.实现协议

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

使用方法:

openStoreProductWithiTunesItemIdentifier(标识符:“here_put_your_App_id”)

注意:

输入你的APP的确切ID是非常重要的。因为这会导致错误(不显示错误日志,但没有任何工作正常,因为这个)


根据苹果公司的最新文件 你需要使用

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

SKStoreProductViewController 

尽管这里有很多答案,但没有一个链接到开发者应用程序的建议似乎已经不管用了。

当我上次访问时,我能够使用以下格式让它工作:

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

这不再有效,但删除开发人员名称可以:

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

它会直接打开应用商店

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

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

所有的答案都过时了,不管用;使用下面的方法。

开发人员的所有应用: itms-apps: / / apps.apple.com/developer/developer-name/developerId

单一应用程序: itms-apps: / / itunes.apple.com/app/appId


我认为苹果已经为应用程序链接提供了一个新的链接: https://apps.apple.com/app/id1445530088或https://apps.apple.com/app/ {your_app_id}


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

这里的大多数解决方案都过时了

为那些寻找更新的工作解决方案

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