如何链接到应用程序商店的应用程序

我正在创build我的iPhone游戏的免费版本。 我想在免费版里面有一个button,让用户可以在app store中收费。 如果我使用标准链接

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

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

有任何想法吗? 什么是应用程序商店的urlscheme?

编辑于2016-02-02

从iOS 6开始,引入了SKStoreProductViewController类。 您可以在不离开您的应用的情况下链接应用。 Swift 3.x / 2.xObjective-C中的代码片段就在这里 。

SKStoreProductViewController对象提供了一个商店,允许用户从App Store购买其他媒体。 例如,您的应用可能会显示商店,以允许用户购买其他应用。


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

通过iTunes链接将客户直接带到App Store上的应用程序通过iTunes链接,您可以直接从您的网站或市场营销活动为您的客户提供在App Store上访问您的应用程序的简单方法。 创buildiTunes链接非常简单,可以将客户引导至单个应用程序,所有应用程序或指定了公司名称的特定应用程序。

要将客户发送到特定应用程序: http : //itunes.com/apps/appname

要将客户发送到App Store上的应用程序列表: http : //itunes.com/apps/developername

要将客户发送到包含在url中的公司名称的特定应用程序: http : //itunes.com/apps/developername/appname


补充笔记:

您可以用itms://itms-apps://replacehttp:// itms-apps://以避免redirect。

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

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

编辑(截至2015年1月):

itunes.com/apps链接应该更新到appstore.com/apps。 参见上面已更新的QA1633。 一个新的QA1629build议这些步骤和代码从应用程序启动商店:

  1. 在电脑上启动iTunes。
  2. search您要链接到的项目。
  3. 在iTunes中右键单击或按住Control键并点按该项目的名称,然后从popup式菜单中select“复制iTunes Store URL”。
  4. 在您的应用程序中,使用复制的iTunes URL创buildNSURL对象,然后将此对象传递给UIApplicationopenURL :方法以在App Store中打开您的项目。

示例代码:

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

Swift 3.0

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

如果你想直接打开一个应用程序到App Store,你应该使用:

ITMS-应用:// …

这样,它将直接在设备上打开App Store应用程序,而不是先到iTunes,然后只打开App Store(只使用itms://时)

希望有所帮助。


编辑:2017年4月。itms-apps://实际上在iOS10中再次工作。 我testing了它。

编辑:四月,2013年。这不再适用于iOS5及以上。 只是使用

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

并没有更多的redirect。

要极其简洁:

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/appname"]]; 

如果您想发送给开发者的所有应用程序,请使用

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/developername"]]; 

这些适用于iOS 4.1

如果你想链接到一个开发者的应用程序,开发者的名字有标点或空格(如开发公司,有限责任公司)形成你的URL这样的:

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://itunes.com/apps/DevelopmentCompanyLLC"]]; 

否则,返回iOS 4.3.3上的“此请求无法处理”

从iOS 6开始,通过使用SKStoreProductViewController类来完成。

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

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

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

此代码在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上的httpreplaceitms-apps:

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

在iOS上打开url:

 [[UIApplication sharedApplication] openURL:appStoreURL]; 

苹果电脑:

 [[NSWorkspace sharedWorkspace] openURL:appStoreURL]; 

苹果刚刚宣布了appstore.com的url。

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

有三种types的App Store短链接,有两种forms,一种适用于iOS应用,另一种适用于Mac Apps:

公司名

iOS: http : //appstore.com/ ,例如http://appstore.com/apple

Mac: http : //appstore.com/mac/ ,例如http://appstore.com/mac/apple

应用名称

iOS: http : //appstore.com/例如http://appstore.com/keynote

Mac: http : //appstore.com/mac/例如http://appstore.com/mac/keynote

应用程序由公司

iOS: http : //appstore.com/ /例如http://appstore.com/apple/keynote

Mac: http : //appstore.com/mac/ /例如http://appstore.com/mac/apple/keynote

大多数公司和应用程序都有一个规范的App Store Short Link。 这个规范的URL是通过更改或删除某些字符(其中许多是非法的或在URL中具有特殊含义(例如“&”))而创build的。

要创buildApp Store短链接,请将以下规则应用于您的公司或应用名称:

删除所有的空格

将所有字符转换为小写

删除所有版权(©),商标(™)和注册标记(®)符号

用“和”replace&符号(“&”)

删除大多数标点符号(请参阅清单2中的集合)

用他们的元素字符(u,a等)replace重音字符和其他“装饰”字符(ü,å等)

保留所有其他字符。

清单2必须删除的标点符号

!¡“#$%'()* +, – 。/ :; <=>¿@ [] ^ _`{|}〜

以下是一些演示发生转换的示例。

app store

公司名称的例子

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

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

陈的摄影与软件=> http://appstore.com/chensphotographyandsoftware

应用名称的例子

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

佩里在哪里? => http://appstore.com/wheresmyperry

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

2015年夏季开始…

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

将“id1234567890”replace为“id”和“你的十位数字”

  1. 这适用于所有设备

  2. 直接进入应用程序商店,没有redirect。

  3. 所有的国内商店都可以

  4. 确实,你应该转向使用 loadProductWithParameters但是如果链接的目的是更新你实际使用的应用程序:最好使用这种“老式”的方法。

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

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

现在它将直接打开App Store

要直接链接而不redirect:

  1. 使用iTunes链接制造商http://itunes.apple.com/linkmaker/获得真正的直接链接;
  2. itms-apps://replacehttp:// itms-apps://
  3. [[UIApplication sharedApplication] openURL:url];打开链接[[UIApplication sharedApplication] openURL:url];

要小心,这些链接只适用于实际的设备,而不是模拟器。

来源: 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]]; 

redirect的数量是零。

许多答案build议使用“itms”或“itms-apps”,但这种做法并不是Apple特别推荐的。 他们只提供以下方式来打开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及更高版本的应用程序,Apple提供了一个展示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 }]; 

请注意,在iOS6上,如果出现错误,则可能不会调用完成块。 这似乎是在iOS 7中解决的错误。

如果你想链接到一个开发者的应用程序,开发者的名字有标点或空格(如开发公司,有限责任公司)形成你的URL这样的:

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

否则,返回iOS 4.3.3上的“此请求无法处理”

您可以通过以下链接获取app store或iTunes中特定商品的链接: http : //itunes.apple.com/linkmaker/

这是工作和直接链接在ios5

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

这是简单和简单的方式来redirect/链接其他现有的应用程序在应用程序商店。

  NSString *customURL = @"http://itunes.apple.com/app/id951386316"; if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:customURL]]) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURL]]; } 

我可以确认,如果你在iTunes中创build一个应用程序连接,你提交之前得到你的应用程序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]; 

作品一种享受

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

有一个名为iLink的开源库可以帮助你。

这个库的优点是, 链接将在运行时被发现和创build (库将检查应用程序ID和它正在运行的操作系统,并将找出应该创build什么链接)。 最好的一点是,在使用它之前不需要configuration几乎所有的东西,这样就没有错误,并且总能正常工作。 如果你在同一个项目中有很less的目标,那么你也不用记得要使用哪个应用ID或链接。 如果用户同意,这个库也会提示用户升级应用程序,如果商店有新版本(这是内置的,你打开一个简单的标志),直接指向应用程序的升级页面。

将2个库文件复制到您的项目(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的示例项目。

如果您有app storeID,则最好使用它。 尤其是如果您将来可能会更改应用程序的名称。

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

如果您没有app store标识,则可以根据此文档创build一个urlhttps://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; } 

通过这个testing

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

至lessiOS 9及以上

  • 直接在App Store中打开

一个应用程序

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

开发者的应用程序列表

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

试试这个方法

http://itunes.apple.com/lookup?id= “你的应用程序ID在这里”返回json.From,find关键“ trackViewUrl ”和值是所需的url。 使用这个url(只需将https://replace为itms-apps:// )即可。

例如,如果您的应用程序ID是xyz,请转至此链接http://itunes.apple.com/lookup?id=xyz

然后find关键字“ 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]]; 

谢谢