On the iPhone, how can you cause a URL to display an entry in the App Store?

六月ゝ 毕业季﹏ 提交于 2019-12-01 06:38:05
Matthew Frederick

EDITED for a better answer:

There's a specific url type for the App Store. Using it will prevent Safari and iTunes from popping up first. The App Store link is:

itms-apps://

As an example, you could do this in response to the user tapping a button (or whatever action):

[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"itms-apps://yourAppLinkHere"]];

You can get the correct app link from the iTunes Link Maker at http://itunes.apple.com/linkmaker

In the case of one of my apps, it would look like this:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"itms-apps://itunes.apple.com/us/app/its-on-my-way/id334996949?mt=8&uo=4"]];

App Store uses the following url format for apps:

http://itunes.com/app/your-app-name

so you can use the following code to open the url:

- (void) buyButtonPressed{
    NSURL *url = [NSURL URLWithString:@"http://itunes.com/app/your-app-name"];
    [[UIApplication sharedApplication] openURL:url];    
}

You should be able to simply copy the URL straight out of iTunes and use that on your website. Mobile Safari will automatically detect that it should open the App Store.

To get the URL just open up iTunes, find the title you're looking for, right click it and click copy link. Here's one I just grabbed, try it on your phone.

http://itunes.apple.com/us/app/flipboard/id358801284?mt=8

Edit - oh, are we talking about from Objective-C or from a website? Sorry, that wasn't completely clear.

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