Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the App Store website know if iTunes is installed?

As a user, I really love how the Apple App Store website on a browser can tell if I have iTunes installed or not and can act accordingly.

For example, if I go to an App's page like "Remember the Milk": http://itunes.apple.com/app/remember-the-milk/id293561396?mt=8 and then click on the "View in iTunes" button,

  1. If I have iTunes installed, it will launch the link in iTunes
  2. If I don't have iTunes, I get redirected to a page that let's me know that I need to download/install iTunes first.

I am trying to do something very similar with a product of ours. We've investigated using url procols like app_name://url_to_open and this works really well if the user already has the program installed and the url protocol is registered to it.

However, if they don't, then they get an error message that doesn't tell them what specifically they need.

I'd like to have more of the iTunes experience where I can help point our users in a more informative manner.

like image 207
J J Avatar asked Aug 19 '10 21:08

J J


1 Answers

Looking at the Javascript resources linked to the page, there is a function called "DetectItunesDetected". It seems to:

  • see if a cookie with the name "iTunesPresent" is set and the computer is a Macintosh (by checking the user agent)
  • see if Internet Explorer is running (again, user agent) and iTunes' ActiveX component is installed
  • see if Firefox is running and the iTunes plugin for Mozilla-based browsers is installed.

If the function returns true, it replaces the relevant HTTP links with ITMS variants.

like image 55
Martey Avatar answered Dec 24 '22 10:12

Martey