Search code examples
ioshyperlinkitunesuiapplicationdelegate

Link from App to an iTunes artist through button


I'm trying to link to an artists iTunes 'page' through a button on my project. I've tried to use their safari page e.g. "http://itunes.apple.com/au/artist/blink-182/id116851" and it worked once but it only showed their page in safari. I would like to direct them to the artists page on the iTunes store app. I have read other questions and they all seem to be how to link to an app on the app store, but nothing about iTunes store. Here is my code for the button:

-(IBAction)ofwebsite2 {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/au/artist/blink-182/id116851"]];
}

I have tried adding itms:// instead of the http:// but that still didn't work.


Solution

  • Adding itms:// instead of http:// should work as this is the only proper way to do it. Even if you leave it as http, it should open safari, then redirect to iTunes app.

    And please note that this will only work in a device, not in simulator.