1

I use i-tunes in-app links like:

NSString *app_link = @"samuraivszombiesdefense";
NSString *link = [@"itms-apps://itunes.com/apps/"stringByAppendingString:app_name];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:link]];

Do somebody happen to know: what is this 'app name' - name of application record (except forbidden symbols) created in itunes (what you can see on iTunesConnect->'Manage Your Apps' screen) or 'App Name' field from 'Metadata and uploads' when editing version details in iTunesConnect?

I mean if app's metadata has many languages, 'App Name' for every language is different. Will link like 'itms-apps://itunes.com/apps/appname' work if appname will be english app name?

Tertium
  • 6,049
  • 3
  • 30
  • 51

3 Answers3

1

Ok, here's my solution. I decided to use URLs like: http://itunes.apple.com/app/idXXXXXXXXX?mt=8, where XXXXXXXXX - my app's id. There is no country prefix, so I suppose it will work global, not only in USA or Germany. Or not?

This kind of links can cause multiple redirects. So to avoid them I've used such code (based on code from Apple docs and works pretty well):

   @interface iTunesOpener ()
{
    NSURL *iTunesURL;
}

- (void)openAppLinkFromAppId:(NSString *) appid;

- (void)openReferralURL:(NSURL *)referralURL;

- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response;

- (void)connectionDidFinishLoading:(NSURLConnection *)connection;

@end


@implementation iTunesOpener

- (void)openAppLinkFromAppId:(NSString *) appid
{
    NSString *iTunesLink = [NSString stringWithFormat:@"http://itunes.apple.com/app/id%@?mt=8", appid];
    NSURL* url = [NSURL URLWithString:iTunesLink];
    [self openReferralURL: url];
}

// Process a LinkShare/TradeDoubler/DGM URL to something iPhone can handle
- (void)openReferralURL:(NSURL *)referralURL
{
    NSURLConnection *con = [[NSURLConnection alloc] initWithRequest:[NSURLRequest requestWithURL:referralURL] delegate:self startImmediately:YES];
    [con release];
}

// Save the most recent URL in case multiple redirects occur
// "iTunesURL" is an NSURL property in your class declaration
- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response
{
    iTunesURL = [response URL];
    if( [iTunesURL.host hasSuffix:@"itunes.apple.com"])
    {
        [connection cancel];
        [self connectionDidFinishLoading:connection];
        return nil;
    }
    else
    {
        return request;
    }
}

// No more redirects; use the last URL saved
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    [[UIApplication sharedApplication] openURL:iTunesURL];
}

@end
Tertium
  • 6,049
  • 3
  • 30
  • 51
0

Edit: App's link will not work if you just use the same link for all countries. Because the link in different country is different. For example Facebook's link in China has a '/cn' between '/com' and '/app'. See the picture:enter image description here


To be extreamly 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"]];

If you want to open a specific app with your company name included in the URL:

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

And you can refer to this question for more:How to link to apps on the app store

Community
  • 1
  • 1
sunkehappy
  • 8,970
  • 5
  • 44
  • 65
  • Did you read my question, @sunkehappy? You've just written the answer from another question I read before. I've asked about what this 'app name' is - name of app record in itumes connect or 'app name' from metadata? – Tertium Nov 20 '12 at 14:47
  • I see, @sunkenhappy, but if I'm not using 'us' or 'de', simply itms-apps://itunes.com/apps/samuraivszombiesdefense, won't it work in all countries? – Tertium Nov 20 '12 at 16:18
  • I don't think so. All the apps I see in China's AppStore will have a '/cn'. You can have a try. I'm not 100% sure. – sunkehappy Nov 21 '12 at 00:51
  • But if you remove "/cn" from the address, itunes will redirect you to the adress with "/cn". At least this works for "/us". – Tertium Nov 21 '12 at 06:14
  • Hmm, sounds you can use the same English name for your app in all countries and you can simply use itms-apps://itunes.com/apps/samuraivszombiesdefense. Do you think so? – sunkehappy Nov 21 '12 at 06:38
0

The best solution we've found is to avoid trying to predict the URL, and create a custom URL redirect like http://mycompany.com/redirects/my-app-itunes which you can update to redirect to the correct URL once you know it.

The exact string you must use is difficult to get right, especially when you have special characters, spaces etc. The rules might even change, or Apple could decide to change something. It's best to keep the URL under your control.

If you really want to go this route, see this documentation from Apple. It details exactly what you need to do to transform the app name into a short friendly iTunes URL:

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

The application name should be the name as it appears in iTunes Connect's application list (non-localized). The best thing is to test this however.

Finally, from Apple:

These itunes.com URLs are provided as a convenience and are not guaranteed to link to a particular application or company. Be sure to test your URLs before using them in any marketing or other public materials. If there are naming conflicts, continue using the standard itunes.apple.com URLs, which contain a unique numerical identifier within the URL.

Mike Weller
  • 45,401
  • 15
  • 131
  • 151
  • Very well @MikeWeller, but when you use redirect what URL do you use to point to your app? I mean if there are different links in every country it looks almost impossible to link to my own app, except local US market? – Tertium Nov 20 '12 at 16:17
  • 1
    If you have a different app for each market, each with its own link, then you'll have to include the user's locale in the URL somehow, then redirect to the appropriate app based on that. Is your app linking to itself, or to *other* apps in the store? – Mike Weller Nov 21 '12 at 08:02
  • This is the lite version pointing to the full one. I've added my own answer (about using link like http://itunes.apple.com/app/idXXXXXXXXX?mt=8). Looks like it more predictable than symbol links in any country. Now it works (I think). What do you think? – Tertium Nov 21 '12 at 15:00