Senthilkumar
Senthilkumar

Reputation: 2481

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.

Upvotes: 5

Views: 13052

Answers (3)

palaniraja
palaniraja

Reputation: 10492

It will work only with device. Throws Request could not be completed on simulator.

Upvotes: 10

Nishant B
Nishant B

Reputation: 2897

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.

Upvotes: 13

PengOne
PengOne

Reputation: 48398

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"]];         

Upvotes: 11

Related Questions