How to open itunes link in iphone app?

I am trying to open an itunes link on UIControlEventTouchDowna click event button. 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 on the device and open the itunes repository. But I get a warning message saying

Your request could not be completed.

Please give an idea with a code.

+5
source share
3 answers

First, copy the URL from iTunes that you want to open in the application.

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 the value of the URLWithString will be your URL of the application you want to open.

Let me know in case of any difficulties.

+13
source

itms-apps:// iTunes,

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

It will only work with the device. The request cast cannot be completed on the simulator.

+10
source

All Articles