Tuesday, January 26, 2010

iTunes "deep links" demystified: How to link to iTunes/App Store content

Last week Don posted an entry on Creating easy-to-read links to the App Store for your applications and company, to which I would like to add a few little gems of knowledge that we have learned while dealing with linking to iTunes and its content.

Apple recently create a few different way to create/generate links to the iTunes and App Store - making it easier for developer and average people alike to link to content.  First a quick overview of the ways to link to content in iTunes.


Creating links from within iTunes
Apple has made it easy for people to share links to music, movies, television shows and apps within iTunes.  All you need to do is open iTunes, navigate to your desired content and then either right-click (control-click) on the album image or the disclosure triangle next to the BUY button and you are presented with a menu - pick Copy Link.

 


These are just a couple of ways to pull the information.  Apple has also added ways to share links via Facebook, Twitter and via email.

So what does this give you?  Well in the case of Mr. Bowie's latest live concert album, it gives you the following link:
http://itunes.apple.com/us/album/a-reality-tour-bonus-track-version/id349978359

And what's new about this link is not that it has the standard web redirect, but Apple now has an "iTunes Preview" web page that is much like the iTunes view:

iTunes (above)


web page (above)

Now how does this translate for movies and television shows?  Lets look at Whip It (movie) directed by Drew Barrymore:


Clicking on the disclosure triangle and selecting Copy Link gives us the following:
http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewMovie?id=333687225&s=143441

When clicking on the link we are presented with the earlier behavior of the iTunes links.  That is to say a we are presented with a web page that gives us a redirection and then launches iTunes.



So what do we see that is different between the first link and the second link?  They both start with http://www.itunes.apple.com, but that is where the simularity ends.  What happens with the first link (Music) is it is sent to a web page with the content inline, as the second link (with the WebObjects path), actually generates a page and then redirects internally to the following link (which launches iTunes):
itms://itunes.apple.com/WebObjects/MZStore.woa/wa/viewMovie?id=333687225

Notice that the prootcal is not "http" but rather "itms" for iTunes Music Store.  This tells your computer to launch iTunes and then direct itself to the ID (333687225).

Great, so we have two different behaviors from the iTunes linking mechanism.  But wait, there's more!

Linking to apps in the App Store (within iTunes) works much the same way as movies and television shows.  A Copy Link process gives you a link to the app much like the music link (for instance, The White House app):
http://itunes.apple.com/us/app/the-white-house/id350190807?mt=8

It looks the same as the music link with the iTunes Preview, but it functions like the movie link with a generated redirection page and then launches iTunes and loads the apps landing page.


iTunes Link Maker (iTMS Link Maker)
The other way to make links is to use the iTunes Link Maker.  We've all seen the following image that links to iTunes:



This image and it's associated link are generated by iTunes Link Maker by going to the site and searching for the content in iTunes that you want to link to.  The process is simple.

1.) Go to the iTunes Link Maker web page (link).


2.) Enter the item or artist you wish to link to then click Search.


3.) Click on the "arrow" button for the specific item you wish to link to (Orchard's Craps APP).


4.) Copy and paste the generated HTML link into your web page and presto, you have your own iTunes link.


The final link looks like this:
Orchard's Craps
It looks just like the first iTunes button above, but this one opens a web page, then launches iTunes and then redirects to the Orchard's Craps landing page.


Deep Links (for Apps)
Deep Links are new and is what the gist of Don's blog entry is about.  Apple has made it easier for use to link to content in iTunes and the App Store.  Deep Links are simple and straight forward.  A link is created using the prefix http://itunes.com/apps/ and come in three flavors, links to apps, links to your company's apps or a hybrid link to your company's app.



For app developers the problem with deep links is symbols or punctuation in an app.  We need to remove the symbols for the app name to create the deep link.  Remove the following characters:
!¡"#$%'()*+,\-./:;<=>¿?@[\]^_`{|}~
But what happens if we have an app with a character and there is another application without the character?

As an example we have a series of apps that have a "?" (question mark) at the end of their names; such as Animals?, People? and Places? and if I try to use the simple (application) Deep Link with the following link:
http://itunes.com/apps/animals it takes you to iTunes but not to the app bur rather to a iTunes search result page with "Animals" as the search search term.

To counter this we use the company/app link: http://itunes.com/apps/ablepearsoftware/animals and this will point directly to our application.  Nice.

So now we have a simple way to generate links for our products.  Simple and concise.  But will this work with making links that work within our apps?  The short answer is yes, it will, but the longer answer is, no, not the way you'd want it to work.


Launch the App Store within iPhone/iPod touch apps.
Recently we've been designing our App Catalogue, which we will be pushing out to all of our applications.  It is a directory of all of our apps (sans the current app you are using to review the app catalogue) and has a description of the app as well as a link to the App Store.

The problem with the linking system above is that if we were to use the links in our apps to link to the App Store a series of redirect happen.  You touch the link and then Safari launches, it generates its redirect page and then starts the redirect, then App Store launches and then the app is presented - but that is not the desired effect.

We want our App Catalogue to launch App Store when the link is tapped, not the long way around via Safari.  So how do we combat this?  Well Apple has a reference to an article on Launching the App Store from within an Application (QA1629) which since is missing... so I'll explain what we do.

On our blog, website, and other web links we use the company/app deep link, but for our internal iPhone /iPod touch apps, we use the old phobos link with the application ID.  You can find your application ID by logging into iTunes Connect and managing your applications, list them all, or get details of a particular application.

The linking mechanism on the iPhone/iPod touch is as follows:

http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=308930648&mt=8

Where the ID (bold) is the application ID.  So now that we have an absolute URL that will launch App Store from within our app, all we need to do is the openURL part of it.  As we have our App Catalogue both hardcoded and served up via JSON, we include the URL in the feed (just in case we need to change it).  Our call is simple:


- (IBAction)openAppStoreUrl {
  NSURL *appStoreUrl = [NSURL URLWithString:[application objectForKey:@"appStoreUrl"]];
  [[UIApplication sharedApplication] openURL:appStoreUrl];
}

and the appStoreURL is (a clip from our JSON respons):

"appStoreUrl": "http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=308930648&mt=8"


So when we attach the IBAction to the button to make the call, the URL is opened, in effect our app is closed and the App Store opens and takes the user to the application.  Nice.  Now we have a direct way to market our other apps.

So there you have it.  Linking to music, movies, T.V., shows and applications as either a link in web pages, or in use in an iPhone/iPod touch application.

How do you use Deep Links?  Do you use Deep Links?  How do you create your links to iTunes or to the App Store?  Was this article helpful?  Let us know by commenting bellow.  Also, take a moment to follow us on Twitter or join our mailing list.  Cheers!

1 comment:

Admin said...

I would be happy that works ... but
when i search for all my apps I always get

This is my Link:
itms://itunes.com/apps/christianalbertmueller

It works fine on my Desktop Safari. But when i call this URL from my iPhone I get the Message:

"Cannot connect to the iTunes Store "The iTunes Store is not supported in this country""

But i know another app, that do something like that and there is no errormessage (i already wrote the developer, just did not got an answer what link he use)

Any Idea...??