简体   繁体   English

如何直接从我的应用程序启动Appstore应用程序

[英]How Can I Launch The Appstore App Directly from my Application

I've used several apps now that launch the itunes store directly from the app. 我现在使用了几个应用程序直接从应用程序启动itunes商店。 I'm even using some on my 2.1 iPod 2G. 我甚至在2.1 iPod 2G上使用了一些。

I know there's a bug in 2.1 that prevents appstore links from working in safari, but somehow people are launching the appstore directly, not even through safari. 我知道2.1中有一个错误阻止appstore链接在safari中工作,但不知何故人们直接启动appstore,甚至没有通过safari启动。

How do you do this? 你怎么做到这一点? Is it an undocumented openURL feature? 它是一个未记录的openURL功能吗?

To be extremely concise: 要非常简洁:

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

If you want to send to all the apps for a developer, use 如果要发送给开发人员的所有应用程序,请使用

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

These work for iOS 4.1 这些适用于iOS 4.1

See Also How to link to apps on the app store 另请参阅如何链接到应用商店中的应用

From iTunes, drag the icon of your app to the desktop, this will give you a link you can use directly (for example, 在iTunes中,将应用程序的图标拖到桌面上,这将为您提供可以直接使用的链接(例如, http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=284036524&mt=8 launches the AppStore to Crosswords, both on a desktop and an iPhone). http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=284036524&mt=8在桌面和iPhone上启动AppStore到Crosswords。

Pop this into an NSURL and call openURL on it. 将其弹出到NSURL并在其上调用openURL。

I figured out how to get straight into the review page for an app in the AppStore. 我想出了如何直接进入AppStore中应用程序的评论页面。

Basically it's done like below, feel free to read my blog post about it. 基本上它完成如下,随时阅读我的​​博客文章

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

If you want to show the details of the application instead of the reviews, you can use the url like this: 如果要显示应用程序的详细信息而不是评论,可以使用以下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]];

I've tested this on my iPhone with iOS 6.1 and will redirect you to the App Store app immediately. 我已经在iOS 6.1上使用iOS 6.1对其进行了测试,并会立即将您重定向到App Store应用程序。

Ben Gottlieb is right, but there's a faster way to get the URL: You can right-click on any application icon in iTunes and select "Copy iTunes Store URL". Ben Gottlieb是对的,但有更快的方法来获取URL:您可以右键单击iTunes中的任何应用程序图标,然后选择“复制iTunes Store URL”。

Then call UIApplication openURL on it. 然后在其上调用UIApplication openURL

您可以从itunesconnect.apple.com“管理您的应用程序”获取您的AppID

Make sure it says "phobos.apple.com" and not "itunes.apple.com" 确保它显示“phobos.apple.com”而不是“itunes.apple.com”

The former opens the App Store directly, while the latter will open MobileSafari first, then the App Store. 前者直接打开App Store,后者首先打开MobileSafari,然后打开App Store。

If you do not want to get the link for iTunes you can do this. 如果您不想获取iTunes的链接,可以执行此操作。

  1. select your app in AppStore 在AppStore中选择您的应用程序
  2. click the Tell A Friend button in the top right. 单击右上角的“告诉朋友”按钮。
  3. email the link to yourself 通过电子邮件发送给自己

I have had this work at time the iTunes link would not. 我有这个工作,iTunes链接不会。

Here is the code I use and tested it against the various iOS versions mentioned. 这是我使用的代码,并针对上面提到的各种iOS版本进行了测试。 Obviously change the customer id to be your one: 显然,将客户ID更改为您的客户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]];
}

If you have an affiliate link and you would like to still open App Store app directly without Safari in the middle, you could use a hidden UIWebView or an NSURLConnection. 如果您有联盟链接,并且您仍希望在没有Safari的情况下直接打开App Store应用程序,则可以使用隐藏的UIWebView或NSURLConnection。 For the latter see this post http://gamesfromwithin.com/handling-app-store-and-linkshare-links 对于后者,请参阅此文章http://gamesfromwithin.com/handling-app-store-and-linkshare-links

If you are just releasing your app... you won't have an "app ID #" yet... so none of those methods will work. 如果你刚刚发布你的应用程序...你还没有“应用程序ID#”......所以这些方法都不会起作用。

I had to insert a "non-working link" in my v1.0... and then later in my v1.1 update... added the actual link and app ID #. 我不得不在我的v1.0中插入一个“非工作链接”...然后在我的v1.1更新中...添加了实际链接和应用程序ID#。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从我的应用程序启动应用商店 - How can I launch app store from my application 我无法将我的应用程序从xcode上传到appstore - I can't upload my app to the appstore from xcode 如何从我的应用程序启动QuickTime? - How can I launch QuickTime from my app? 我如何以编程方式从appstore获知应用程序信息 - How can I know app information from appstore programmatically 如何知道从appstore更新后是否第一个应用启动 - how to know if first app launch after update from appstore iOS:在我的App中启动AppStore页面 - iOS: Launch AppStore page within my App 如果通知被禁用且应用程序在appstore上运行,我可以将pushNotification弹出窗口重新发送到我的iPhone应用程序吗? - Can I resend pushNotification pop-up to my iPhone App if notifications are disabled and application is live on appstore? 如何直接从appCode IDE将应用程序部署到iPhone和appleWatch? - How can I deploy my application directly from appCode IDE to my iPhone and appleWatch? 我可以在iPhone应用程序中使用CoreTelephony而不被AppStore拒绝吗? - Can I use CoreTelephony in my iPhone app without it being rejected from the AppStore? 如何从我的应用程序启动我的设置包? - How do I launch my settings bundle from my application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM