从iPhoneApplication中打开App Store的方法
来源:互联网 发布:linux shell 等待输入 编辑:程序博客网 时间:2024/05/22 01:54
通过用[UIApplicaiont openURL:]方法打开在itunes中的URL来指向你感兴趣的应用,歌曲或者专辑。
先通过以下步骤来获取URL:
1. 在你的MAC上打开itunes。
2. 搜索你想Link到的Item。
3.右键点击或者Ctr-Click iTunes中的你感兴趣的Item,然后再添出的Menu中选择Copy iTunes Store URL,
需要注意的是你现在得到的URL是一个itunes.app.com的Link,iPhone需要的是一个可以直接连接的phoboURLs,
所以你必须进行一些转换。
4.调用[UIApplication openURL]来打开拟修改后的URL。
下面就是你怎么在你的Apllication中打开App Store了。
Listing 1: 直接打开URL
NSString *iTunesLink = @"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=284417350&mt=8"; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
Listing 2: 动态修改URL后打开
NSString *iTunesLink = @"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=284417350&mt=8";NSURL *iTunesURL = [NSURL URLWithString:iTunesLink]; // Produce a phobos.apple.com URL that will open the iTunes or App Store application directly[NSURL URLWithString:[NSString stringWithFormat:@"http://phobos.apple.com%@?%@", iTunesURL.path, iTunesURL.query]];
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 3 demonstrates how to accomplish this.
you can use this technique after intercepting the links with the
-[UIWebViewDelegate webView:shouldStartLoadWithRequest:navigationType:] delegate method.
Listing 3: 有时候一个iTunes Link有很多个指向,你可以用NSURLConnection, 打开最终的URL。
如果你有一个在UIWebView中的Link,你可以在[UIWebViewDelegate webView:shouldStartLoadWithRequest:navigationType:]这个委托中来完成这件事情
// Process a LinkShare/TradeDoubler/DGM URL to something iPhone can handle- (void)openReferralURL:(NSURL *)referralURL { NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:[NSURLRequest requestWithURL:referralURL] delegate:self startImmediately:YES]; [conn 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]; return request;} // No more redirects; use the last URL saved- (void)connectionDidFinishLoading:(NSURLConnection *)connection { [[UIApplication sharedApplication] openURL:self.iTunesLink];}
- 从iPhoneApplication中打开App Store的方法
- 从iPhoneApplication中打开App Store的方法
- 从Spy Mouse看App Store的推广方法
- ios中代码打开app store
- 点击页面判断是否安装app并打开,否则跳转app store的方法
- 点击页面判断是否安装app并打开,否则跳转app store的方法
- 点击页面判断是否安装app并打开,否则跳转app store的方法
- 点击页面判断是否安装app并打开,否则跳转app store的方法
- 点击页面判断是否安装app并打开,否则跳转app store的方法
- 点击页面判断是否安装app并打开,否则跳转app store的方法
- 点击页面判断是否安装app并打开,否则跳转app store的方法
- 点击页面判断是否安装app并打开,否则跳转app store的方法
- 点击页面判断是否安装app并打开,否则跳转app store的方法
- 点击页面判断是否安装app并打开,否则跳转app store的方法
- JS检测是手机否安装App并打开,否则跳转App Store的方法
- 点击页面判断是否安装app并打开,否则跳转app store的方法
- 如何打开itune store上的app
- 从程序中启动App store
- Json整理
- 【转】ORACLE 日志记录存放位置
- QT界面美化之QStyle
- 2009年CRM软件年度分析
- 不要迷失在技术的海洋中
- 从iPhoneApplication中打开App Store的方法
- linux解压命令集
- happy new year
- jsp学习网址
- 深入理解全局编录服务器GC
- [gnuhpc注释版]奥巴马每周电台演讲2010-01-02 视频+音频+文本
- Linxu 设备文件
- Java中的String str="abc"; String str=new String("abc");和String str = new String();的区别以及==与equals()的不同。
- 不可错过的让你年轻10岁的蔬菜