Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iTunes Store as Modal view

I would like to open some iTunes song's link in my app, but I don't want to redirect from my app to app store. I would like to open iTunes Store as a modal view like Facebook do it when you press on a sponsored app. How can I do it? ( in "home made" modal view with web view?? I hope not )

For example how to open this link as a modal view, and user can buy right there: @"https://itunes.apple.com/us/album/how-i-feel/id731197191?i=731197197&ign-mpt=uo%3D4"

Right now I'm using this:

[[UIApplication sharedApplication]
 openURL:[NSURL URLWithString:@"itms://itunes.apple.com/us/album/how-i-feel/id731197191?i=731197197&uo=4"]];

Of course it won't open in a modal view.

like image 526
Magyar Miklós Avatar asked Dec 22 '25 04:12

Magyar Miklós


1 Answers

Ok, so I' ve solved my problem, and I won't delete my question, because I didn't find it in stack overflow :

SKStoreProductViewController *storeProductViewController = [[SKStoreProductViewController alloc] init];

[storeProductViewController setDelegate:self];
[storeProductViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @"731197191"} completionBlock:^(BOOL result, NSError *error) {
    if (error) {
        NSLog(@"Error %@ with User Info %@.", error, [error userInfo]);

    } else {
        // Present Store Product View Controller
        [self presentViewController:storeProductViewController animated:YES completion:nil];
    }
}];
like image 123
Magyar Miklós Avatar answered Dec 23 '25 17:12

Magyar Miklós