【发布时间】:2008-10-22 18:24:41
【问题描述】:
我现在使用了几个直接从应用程序启动 iTunes 商店的应用程序。我什至在我的 2.1 iPod 2G 上使用了一些。
我知道 2.1 中有一个错误会阻止应用商店链接在 safari 中工作,但不知何故人们直接启动了应用商店,甚至通过 safari 也不行。
你是怎么做到的?它是一个未记录的 openURL 功能吗?
【问题讨论】:
我现在使用了几个直接从应用程序启动 iTunes 商店的应用程序。我什至在我的 2.1 iPod 2G 上使用了一些。
我知道 2.1 中有一个错误会阻止应用商店链接在 safari 中工作,但不知何故人们直接启动了应用商店,甚至通过 safari 也不行。
你是怎么做到的?它是一个未记录的 openURL 功能吗?
【问题讨论】:
非常简洁:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/appname"]];
如果您想为开发者发送到所有应用,请使用
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/developername"]];
这些适用于 iOS 4.1
【讨论】:
从 iTunes 中,将您的应用程序的图标拖到桌面,这将为您提供一个可以直接使用的链接(例如,http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=284036524&mt=8 在桌面和 iPhone 上启动 AppStore 到填字游戏) .
将其放入 NSURL 并在其上调用 openURL。
【讨论】:
我想出了如何直接进入 AppStore 中应用的评论页面。
基本上是这样完成的,请随时阅读我的博客post。
- (IBAction)gotoReviews:(id)sender
{
NSString *str = @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa";
str = [NSString stringWithFormat:@"%@/wa/viewContentsUserReviews?", str];
str = [NSString stringWithFormat:@"%@type=Purple+Software&id=", str];
// Here is the app id from itunesconnect
str = [NSString stringWithFormat:@"%@289382458", str];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}
【讨论】:
如果您想显示应用程序的详细信息而不是评论,您可以使用这样的 url:
NSString *appId = @"app id";
NSString *endPoint = [NSString stringWithFormat:@"phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=%@&mt=8", appId];
NSString *link = [NSString stringWithFormat:@"itms-apps://%@", endPoint];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:link]];
我已在装有 iOS 6.1 的 iPhone 上对此进行了测试,并将立即将您重定向到 App Store 应用。
【讨论】:
Ben Gottlieb 是对的,但有一种更快的获取 URL 的方法:您可以右键单击 iTunes 中的任何应用程序图标,然后选择“复制 iTunes Store URL”。
然后拨打UIApplication openURL就可以了。
【讨论】:
确保显示的是“phobos.apple.com”而不是“itunes.apple.com”
前者直接打开App Store,后者会先打开MobileSafari,再打开App Store。
【讨论】:
您可以从 itunesconnect.apple.com“管理您的应用程序”获取您的 AppID
【讨论】:
如果您不想获得 iTunes 的链接,您可以这样做。
我在 iTunes 链接没有的时候做过这项工作。
【讨论】:
如果你有一个附属链接,并且你想在没有 Safari 的情况下直接打开 App Store 应用程序,你可以使用隐藏的 UIWebView 或 NSURLConnection。对于后者,请参阅此帖子http://gamesfromwithin.com/handling-app-store-and-linkshare-links
【讨论】:
这是我使用的代码,并针对提到的各种 iOS 版本对其进行了测试。显然将客户 ID 更改为您的:
- (void)showOurAppsInAppStore
{
NSString *searchUrl = nil;
// iPad
if ([DeviceController isDeviceAnIpad]) {
searchUrl = @"itms-apps://itunes.apple.com/us/artist/seligman-ventures-ltd/id326161338";
}
// iPhone / iPod Touch
else {
// iOS 7+
if ([DeviceController isDeviceOperatingSystemAtleast:@"7.0"]) {
searchUrl = @"itms-apps://itunes.apple.com/artist/seligman-ventures-ltd/id326161338";
}
// iOS 6
else if ([DeviceController isDeviceOperatingSystemAtleast:@"6.0"]) {
searchUrl = @"itms-apps://ax.itunes.apple.com/artist/seligman-ventures-ltd/id326161338";
}
// Pre iOS 6
else {
NSString *companyName = @"Seligman Ventures";
searchUrl = [NSString stringWithFormat:@"http://phobos.apple.com/WebObjects/MZSearch.woa/wa/search?WOURLEncoding=ISO8859_1&lang=1&output=lm&country=US&term=%@&media=software", [companyName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
}
}
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:searchUrl]];
}
【讨论】:
如果您只是发布应用程序...您还没有“应用程序 ID #”...所以这些方法都不起作用。
我必须在我的 v1.0 中插入一个“无效链接”...然后在我的 v1.1 更新中...添加实际链接和应用 ID #。
【讨论】:
iTunes.com/apps/[yourcompanyname]/[appname],无需 ID。