Q: How do I launch the App Store from my iPhone application? Also, how do I link to my application on the store?
A: The -[UIApplication openURL:] method handles links to applications and media by launching the appropriate store application for the passed NSURL object. Follow the steps below to obtain a link to an application, song, or album sold on iTunes, and link to it from your iPhone application:
Launch iTunes on your computer.
Search for the item you want to link to.
Right-click or control-click on the item's name in iTunes, then choose "Copy iTunes Store URL" from the pop-up menu.
Open the modified URL using an NSURL object and the -[UIApplication openURL:] method.
Note: You can also use the iTunes Link Maker tool to get a link to an application, song, or album sold on iTunes. See iTunes Link Maker FAQ to learn more about that tool.
See Listing 1 for an example that launches the App Store from a native application.
Listing 1 Launching the App Store from an iPhone application.
NSString *iTunesLink = @"http://itunes.apple.com/us/app/id284417350?mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
Some iTunes links, including iTunes Affiliate links, result in multiple redirections before reaching the appropriate store application. You can process these redirects silently using NSURLConnection, and open the final URL once the redirects are complete. This allows your application to transition right to the store without launching Safari. Listing 2 demonstrates how to accomplish this.
Note: If you have iTunes links inside a UIWebView, you can use this technique after intercepting the links with the -[UIWebViewDelegate webView:shouldStartLoadWithRequest:navigationType:] delegate method.
Listing 2 Processing iTunes Affiliate links in an iPhone application.
// 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
{
self.iTunesURL = [response URL];
if( [self.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:self.iTunesURL];
}
分享到:
相关推荐
This involves accepting an invitation to join the iPhone University Developer Program and downloading the necessary software from Apple's developer website. - **Importance:** Having the latest SDK...
Launching an AIR Application Monetizing Your Application Reporting Conclusion Chapter 5 : Evaluating Device Capabilities and Handling Multiple Devices Hardware Software Creating Content for Multiple ...
Get the Window Title, Active Document, and tell if an App is Running after Shell Launching It Description: This application demonstrates how to get the window title of an application you started with ...
Launching an AIR Application Monetizing Your Application Reporting Conclusion Chapter 5 : Evaluating Device Capabilities and Handling Multiple Devices Hardware Software Creating Content for Multiple ...
Launching an AIR Application Monetizing Your Application Reporting Conclusion Chapter 5 : Evaluating Device Capabilities and Handling Multiple Devices Hardware Software Creating Content for Multiple ...
Launching an AIR Application Monetizing Your Application Reporting Conclusion Chapter 5 : Evaluating Device Capabilities and Handling Multiple Devices Hardware Software Creating Content for Multiple ...
2. **Electron API**:Electron提供了丰富的API,如`app`、`browserWindow`、`menu`和`tray`,这些都是构建桌面应用的核心工具。 3. **Node.js集成**:由于Electron基于Node.js,我们可以直接在应用中使用Node模块...
This is an ActiveX DLL that causes a client app to wait for another... The library takes care of launching the new app and doing all of the synchronization. It also returns the exit code for the process.
Troubleshooting Xcode is a handbook for software developers of all levels creating applications for iOS and OS X using... Check the version of an app on the App Store Chapter 48. Power tips: Beyond Xcode
理解CUDA核启动开销 在GPU计算领域,CUDA核(Kernel)扮演着至关重要的角色。然而,在启动CUDA核时,存在着许多潜在的开销,这些开销可能会对程序的性能产生影响。因此,了解和理解CUDA核启动开销对于优化GPU计算...
### Eclipse中的启动框架 #### 概述 在集成开发环境(IDE)中,启动(运行或调试)正在开发中的代码的能力是基本且重要的。由于Eclipse更多地被视为一个工具平台而非单一工具,其启动功能完全依赖于当前安装的插件...
It discusses how the advances in quantum computing and quantum physics have allowed the building, launching and deploying of space exploration systems that are capable of more and more as they become...
store and save a password to the registry and also encrypts it to keep out prying eyes.<END><br>32,delay.zip This is a rough translation of the GetTickCount API and includes three different ways to...
What you will learnSet up a working development environment and create a simple web service to demonstrate the basicsLearn how to make your service more usable by adding a database and an app server ...
If you want to use this library you must before all indicate to your application that you want to use it by launching the following command from the root directory of your application $ android ...