开发者

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

开发者 https://www.devze.com 2023-01-12 02:54 出处:网络
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.

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开发者_StackOverflow社区 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.


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.


The web site doesn't know, it uses itms protocol.

To create your own you'll need to register your application to the Operating System and tell which protocol it will handle. A good article on that. The windows explanation works with all browsers (which use the register). Others are for firefox only.


I'm not able to test this right this moment, but you could try to load an image from your application using its protocol, if the image can't be loaded, redirect.

<img src='yourProtocol://image.jpg' onerror='window.location="yoursite.com/pageiffails.php";' />
0

精彩评论

暂无评论...
验证码 换一张
取 消