Velmurugan
Velmurugan

Reputation: 2303

Why is this link to an item in iTunes not opening the music store from my application?

I need a user of my application to purchase and download music from iTunes to their iPhone.

I used the following code:

NSString *text=@"<a href=\"http://itunes.apple.com/us/album/sports/id14659264?ign-mpt=uo%3D4\" target=\"itunes_store\"><img src=\"http://ax.phobos.apple.com.edgesuite.net/images/web/linkmaker/badge_itunes-lrg.gif\" alt=\"Esperanza - Esperanza Spalding\" style=\"border: 0;\" /></a>";
[webview loadHTMLString:text baseURL:nil];  

but the iTunes music store is not opening. What could be wrong with this code?

Upvotes: 1

Views: 371

Answers (2)

Ludovic Landry
Ludovic Landry

Reputation: 11774

What you are doing is just displaying an image link in a UIVebView.

If you want to open the iTunes app you can do this:

NSString *link = @"http://itunes.apple.com/us/album/sports/id14659264";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:link]];

Upvotes: 4

WrightsCS
WrightsCS

Reputation: 50707

Your code works fine, you will not be able to run it on the Simulator though.

Upvotes: 1

Related Questions