Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to open itunes link in iphone app?

I am trying to open itunes link on UIControlEventTouchDown button press event. My code is as follows.

    NSString *urlString =@"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];

This will go to itunes in the device and open the itunes store. But i get an alert message that says

Your Request could not be Completed.

Please give idea with code.

like image 571
Senthilkumar Avatar asked Jun 22 '11 05:06

Senthilkumar


2 Answers

First copy the url from iTunes which you want to open in app.

Then use below code:

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

here, URLWithString value will be your app url which you want to open.

Let me know in case of any difficulty.

like image 164
Nishant B Avatar answered Sep 20 '22 18:09

Nishant B


Use the itms-apps:// prefix to open in iTunes, e.g.

[[UIApplication sharedApplication] 
     openURL:[NSURL URLWithString:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=409954448"]];         
like image 42
PengOne Avatar answered Sep 22 '22 18:09

PengOne