2011-06-22 72 views
5

我想打开itunes链接UIControlEventTouchDown按钮按下事件。我的代码如下。如何打开iPhone应用程序中的iTunes链接?

NSString *urlString [email protected]"http://itunes.apple.com/in/album/carnatic-vocal-sanjay-subrahmanyan/id106924807?ign-mpt=uo%3D4"; 


    NSString *str_ur=[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 

    NSURL *url=[NSURL URLWithString:str_ur]; 

    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 
    [webview_buy loadRequest:requestObj]; 

    webview_buy.delegate=self; 

    [self.view addSubview:webview_buy]; 

这将去itunes中的设备,并打开itunes商店。但我收到一条警告消息,说

您的请求无法完成。

请给出代码的想法。

回答

13

首先从iTunes中复制你想要在app中打开的url。

然后使用下面的代码:

[[UIApplication sharedApplication] 
    openURL:[NSURL URLWithString:@"http://itunes.apple.com/in/album/carnatic-vocal-sanjay-subrahmanyan/id106924807?ign-mpt=uo%3D4"]]; 

这里,URLWithString值将是您要打开你的应用程序网址。

如有任何困难,请告知我。

+0

我也使用过这种方法,但我的警报消息相同您的请求无法完成。 – Senthilkumar

+1

请确保以下事项:(1)应用必须在应用商店中生活。 (2)您必须位于应用程序所在的同一家国际商店内。假设你在印度商店。但是,应用程序不适用于印度商店。那么应用程序将无法打开。 (3)应用程序必须可用于该设备。 (iPod,iPhone,iPad)。假设您正在iPhone上测试应用程序。并打开仅适用于iPad的应用程序。然后它不会在iPhone设备上打开。请检查并在遇到困难时通知我。 –

+0

我只使用了上述链接。 – Senthilkumar

11

使用itms-apps://前缀在iTunes中打开,例如,

[[UIApplication sharedApplication] 
    openURL:[NSURL URLWithString:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=409954448"]];   
+0

我也使用这种方法,但我有相同的警报消息您的请求无法完成。 – Senthilkumar

+1

确保有互联网连接。我使用这个n我的应用程序,它很好。 – PengOne

+0

这帮助我在iOS 9,因为每次我试图打开iTunes链接我的音乐应用程序出现。 (而不是购买选项的iTunes应用程序)。非常感谢。 – sig

10

它只适用于设备。抛出请求无法在模拟器上完成。

+0

是的。我也只检查设备。 – Senthilkumar

相关问题