我正在创造自己的iPhone游戏的免费版本。我想在免费版本中添加一个按钮,引导用户进入应用商店中的付费版本。如果我使用标准链接
http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=300136119&mt=8
iPhone首先打开Safari,然后打开应用商店。我使用过其他直接打开应用程序商店的应用程序,所以我知道这是可能的。
什么好主意吗?应用商店的URL方案是什么?
我正在创造自己的iPhone游戏的免费版本。我想在免费版本中添加一个按钮,引导用户进入应用商店中的付费版本。如果我使用标准链接
http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=300136119&mt=8
iPhone首先打开Safari,然后打开应用商店。我使用过其他直接打开应用程序商店的应用程序,所以我知道这是可能的。
什么好主意吗?应用商店的URL方案是什么?
当前回答
编辑于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)!)
}
其他回答
如果你有应用商店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-apps: / / apps.apple.com/developer/developer-name/developerId
单一应用程序: itms-apps: / / itunes.apple.com/app/appId
这里的大多数解决方案都过时了
为那些寻找更新的工作解决方案
// 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)
这是重定向/链接应用商店中其他现有应用程序的简单而简短的方法。
NSString *customURL = @"http://itunes.apple.com/app/id951386316";
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:customURL]])
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURL]];
}
苹果刚刚公布了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