Note that there are some explanatory texts on larger screens.

plurals
  1. POOdd behavior with SKStoreProductViewController
    text
    copied!<p>I am trying to use SKStoreProductViewController to open the App Store modally within my app. I have looked at many examples on the web, and there are two ways people are doing this.</p> <pre><code> SKStoreProductViewController *storeController = [[SKStoreProductViewController alloc] init]; [storeController setDelegate:self]; //set product parameters //must be a number wrapped in a string NSDictionary *productParameters = @{ SKStoreProductParameterITunesItemIdentifier : @"36372693196"}; [storeController loadProductWithParameters:productParameters completionBlock:^(BOOL result, NSError *error) { if (result) { //show [self presentViewController:storeController animated:YES completion:nil]; }else { NSLog(@"ERROR WITH STORE CONTROLLER %@\n", error.description); //redirect to app store //[[UIApplication sharedApplication] openURL:[[self class] appStoreURL]]; } }]; </code></pre> <p>If I do it this way ^^ nothing happens. The if (result) or else statement within the block is never executed.</p> <p>I also see people passing in nil for the completion block, and presenting the view controller modally immediately after this like below:</p> <pre><code> SKStoreProductViewController *storeController = [[SKStoreProductViewController alloc] init]; [storeController setDelegate:self]; //set product parameters //must be a number wrapped in a string NSDictionary *productParameters = @{ SKStoreProductParameterITunesItemIdentifier : @"36372693196"}; [storeController loadProductWithParameters:productParameters completionBlock:nil]; [self presentViewController:storeController animated:YES completion:nil]; </code></pre> <p>When I present the view controller, the code inside the block for loadProductWithParameters executes. I am extremely confused at this point..How do I check for success or failure if the block isn't run until after I present it.</p> <p>Lastly, I read you should execute the loadProductWithParameters in a background thread. I tried this as well. The second option is the only one that brought up the modal - with a Cannot connect to iTunes message from the simulator and device. I have tried multiple app ids. What is going on? How do I get this working?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload