How Can I Launch The Appstore App Directly from my Application

China☆狼群 提交于 2019-11-28 15:40:18

问题


I've used several apps now that launch the itunes store directly from the app. I'm even using some on my 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.

How do you do this? Is it an undocumented openURL feature?


回答1:


From iTunes, drag the icon of your app to the desktop, this will give you a link you can use directly (for example, 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).

Pop this into an NSURL and call openURL on it.




回答2:


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

See Also How to link to apps on the app store




回答3:


I figured out how to get straight into the review page for an app in the 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]];
}



回答4:


If you want to show the details of the application instead of the reviews, you can use the url like this:

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.




回答5:


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

Then call UIApplication openURL on it.




回答6:


Make sure it says "phobos.apple.com" and not "itunes.apple.com"

The former opens the App Store directly, while the latter will open MobileSafari first, then the App Store.




回答7:


You can get your AppID from the itunesconnect.apple.com "Manage Your Applications"




回答8:


If you do not want to get the link for iTunes you can do this.

  1. select your app in 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.




回答9:


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. For the latter see this post http://gamesfromwithin.com/handling-app-store-and-linkshare-links




回答10:


Here is the code I use and tested it against the various iOS versions mentioned. Obviously change the customer id to be your one:

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



回答11:


If you are just releasing your app... you won't have an "app ID #" yet... so none of those methods will work.

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 #.



来源:https://stackoverflow.com/questions/226986/how-can-i-launch-the-appstore-app-directly-from-my-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!