SKStoreProductViewController showing up with delay











up vote
8
down vote

favorite
5












I use in my app the SKStoreProductViewController. It shows up correctly, but with a few seconds of delay, which slows down the user experience.



Is there something wrong in my code ? Or should I inform the user that the VC is loading ? Because right now one can believe that nothing is happening after pressing the button (which triggers the following code) :



-(void)launchApp:(id)sender {

// Recall on main thread if necessary
if (![NSThread isMainThread]) {
[self performSelectorOnMainThread:@selector(launchApp:)
withObject:sender
waitUntilDone:NO];
return;
}

// Initialize Product View Controller
SKStoreProductViewController *storeProductViewController = [[SKStoreProductViewController alloc] init];

// Configure View Controller
[storeProductViewController setDelegate:self];
[storeProductViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @"*********"}
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];
}
}];
}









share|improve this question


























    up vote
    8
    down vote

    favorite
    5












    I use in my app the SKStoreProductViewController. It shows up correctly, but with a few seconds of delay, which slows down the user experience.



    Is there something wrong in my code ? Or should I inform the user that the VC is loading ? Because right now one can believe that nothing is happening after pressing the button (which triggers the following code) :



    -(void)launchApp:(id)sender {

    // Recall on main thread if necessary
    if (![NSThread isMainThread]) {
    [self performSelectorOnMainThread:@selector(launchApp:)
    withObject:sender
    waitUntilDone:NO];
    return;
    }

    // Initialize Product View Controller
    SKStoreProductViewController *storeProductViewController = [[SKStoreProductViewController alloc] init];

    // Configure View Controller
    [storeProductViewController setDelegate:self];
    [storeProductViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @"*********"}
    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];
    }
    }];
    }









    share|improve this question
























      up vote
      8
      down vote

      favorite
      5









      up vote
      8
      down vote

      favorite
      5






      5





      I use in my app the SKStoreProductViewController. It shows up correctly, but with a few seconds of delay, which slows down the user experience.



      Is there something wrong in my code ? Or should I inform the user that the VC is loading ? Because right now one can believe that nothing is happening after pressing the button (which triggers the following code) :



      -(void)launchApp:(id)sender {

      // Recall on main thread if necessary
      if (![NSThread isMainThread]) {
      [self performSelectorOnMainThread:@selector(launchApp:)
      withObject:sender
      waitUntilDone:NO];
      return;
      }

      // Initialize Product View Controller
      SKStoreProductViewController *storeProductViewController = [[SKStoreProductViewController alloc] init];

      // Configure View Controller
      [storeProductViewController setDelegate:self];
      [storeProductViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @"*********"}
      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];
      }
      }];
      }









      share|improve this question













      I use in my app the SKStoreProductViewController. It shows up correctly, but with a few seconds of delay, which slows down the user experience.



      Is there something wrong in my code ? Or should I inform the user that the VC is loading ? Because right now one can believe that nothing is happening after pressing the button (which triggers the following code) :



      -(void)launchApp:(id)sender {

      // Recall on main thread if necessary
      if (![NSThread isMainThread]) {
      [self performSelectorOnMainThread:@selector(launchApp:)
      withObject:sender
      waitUntilDone:NO];
      return;
      }

      // Initialize Product View Controller
      SKStoreProductViewController *storeProductViewController = [[SKStoreProductViewController alloc] init];

      // Configure View Controller
      [storeProductViewController setDelegate:self];
      [storeProductViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @"*********"}
      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];
      }
      }];
      }






      ios storekit






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 14 '13 at 14:53









      rdurand

      6,12633064




      6,12633064
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          33
          down vote



          accepted










          The delay is caused because you present the viewController after the products have been loaded sucesfully.



          You can put the call presentViewController:animated:completion: outside of the block that is called after the products have been loaded. In this case the controller will be presented empty, and it is filled after the products have been loaded.



          Something along those lines:



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

          // Configure View Controller
          [storeProductViewController setDelegate:self];
          [storeProductViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @364709193}
          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];


          Or you could create a "popup" view that shows an activity indicator while the controller loads its content.



          Or you use [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;



          There are a couple of ways to handle this.






          share|improve this answer























          • Thanks, I forgot for a second the logic behind blocks.. I used the first solution and it's fine, as the VC has its own "loading" label. Thanks !
            – rdurand
            May 14 '13 at 15:25






          • 1




            @Matthias - any idea if it's possible to institute a timeout as well for the loadProductWithParameters call?
            – runamok
            Aug 6 '13 at 21:32






          • 1




            One note - Apple says you should pass your store identifier as a NSNumber rather than a NSString.
            – Zack
            Jun 13 '14 at 19:44










          • You're right. I fixed it. Thanks
            – Matthias Bauch
            Jun 13 '14 at 20:55












          • My app got rejected in the App Store. This saved me.
            – vito.royeca
            Jun 21 '16 at 3:08











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f16546431%2fskstoreproductviewcontroller-showing-up-with-delay%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          33
          down vote



          accepted










          The delay is caused because you present the viewController after the products have been loaded sucesfully.



          You can put the call presentViewController:animated:completion: outside of the block that is called after the products have been loaded. In this case the controller will be presented empty, and it is filled after the products have been loaded.



          Something along those lines:



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

          // Configure View Controller
          [storeProductViewController setDelegate:self];
          [storeProductViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @364709193}
          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];


          Or you could create a "popup" view that shows an activity indicator while the controller loads its content.



          Or you use [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;



          There are a couple of ways to handle this.






          share|improve this answer























          • Thanks, I forgot for a second the logic behind blocks.. I used the first solution and it's fine, as the VC has its own "loading" label. Thanks !
            – rdurand
            May 14 '13 at 15:25






          • 1




            @Matthias - any idea if it's possible to institute a timeout as well for the loadProductWithParameters call?
            – runamok
            Aug 6 '13 at 21:32






          • 1




            One note - Apple says you should pass your store identifier as a NSNumber rather than a NSString.
            – Zack
            Jun 13 '14 at 19:44










          • You're right. I fixed it. Thanks
            – Matthias Bauch
            Jun 13 '14 at 20:55












          • My app got rejected in the App Store. This saved me.
            – vito.royeca
            Jun 21 '16 at 3:08















          up vote
          33
          down vote



          accepted










          The delay is caused because you present the viewController after the products have been loaded sucesfully.



          You can put the call presentViewController:animated:completion: outside of the block that is called after the products have been loaded. In this case the controller will be presented empty, and it is filled after the products have been loaded.



          Something along those lines:



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

          // Configure View Controller
          [storeProductViewController setDelegate:self];
          [storeProductViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @364709193}
          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];


          Or you could create a "popup" view that shows an activity indicator while the controller loads its content.



          Or you use [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;



          There are a couple of ways to handle this.






          share|improve this answer























          • Thanks, I forgot for a second the logic behind blocks.. I used the first solution and it's fine, as the VC has its own "loading" label. Thanks !
            – rdurand
            May 14 '13 at 15:25






          • 1




            @Matthias - any idea if it's possible to institute a timeout as well for the loadProductWithParameters call?
            – runamok
            Aug 6 '13 at 21:32






          • 1




            One note - Apple says you should pass your store identifier as a NSNumber rather than a NSString.
            – Zack
            Jun 13 '14 at 19:44










          • You're right. I fixed it. Thanks
            – Matthias Bauch
            Jun 13 '14 at 20:55












          • My app got rejected in the App Store. This saved me.
            – vito.royeca
            Jun 21 '16 at 3:08













          up vote
          33
          down vote



          accepted







          up vote
          33
          down vote



          accepted






          The delay is caused because you present the viewController after the products have been loaded sucesfully.



          You can put the call presentViewController:animated:completion: outside of the block that is called after the products have been loaded. In this case the controller will be presented empty, and it is filled after the products have been loaded.



          Something along those lines:



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

          // Configure View Controller
          [storeProductViewController setDelegate:self];
          [storeProductViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @364709193}
          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];


          Or you could create a "popup" view that shows an activity indicator while the controller loads its content.



          Or you use [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;



          There are a couple of ways to handle this.






          share|improve this answer














          The delay is caused because you present the viewController after the products have been loaded sucesfully.



          You can put the call presentViewController:animated:completion: outside of the block that is called after the products have been loaded. In this case the controller will be presented empty, and it is filled after the products have been loaded.



          Something along those lines:



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

          // Configure View Controller
          [storeProductViewController setDelegate:self];
          [storeProductViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @364709193}
          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];


          Or you could create a "popup" view that shows an activity indicator while the controller loads its content.



          Or you use [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;



          There are a couple of ways to handle this.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 13 '14 at 20:54

























          answered May 14 '13 at 15:05









          Matthias Bauch

          82.8k15205241




          82.8k15205241












          • Thanks, I forgot for a second the logic behind blocks.. I used the first solution and it's fine, as the VC has its own "loading" label. Thanks !
            – rdurand
            May 14 '13 at 15:25






          • 1




            @Matthias - any idea if it's possible to institute a timeout as well for the loadProductWithParameters call?
            – runamok
            Aug 6 '13 at 21:32






          • 1




            One note - Apple says you should pass your store identifier as a NSNumber rather than a NSString.
            – Zack
            Jun 13 '14 at 19:44










          • You're right. I fixed it. Thanks
            – Matthias Bauch
            Jun 13 '14 at 20:55












          • My app got rejected in the App Store. This saved me.
            – vito.royeca
            Jun 21 '16 at 3:08


















          • Thanks, I forgot for a second the logic behind blocks.. I used the first solution and it's fine, as the VC has its own "loading" label. Thanks !
            – rdurand
            May 14 '13 at 15:25






          • 1




            @Matthias - any idea if it's possible to institute a timeout as well for the loadProductWithParameters call?
            – runamok
            Aug 6 '13 at 21:32






          • 1




            One note - Apple says you should pass your store identifier as a NSNumber rather than a NSString.
            – Zack
            Jun 13 '14 at 19:44










          • You're right. I fixed it. Thanks
            – Matthias Bauch
            Jun 13 '14 at 20:55












          • My app got rejected in the App Store. This saved me.
            – vito.royeca
            Jun 21 '16 at 3:08
















          Thanks, I forgot for a second the logic behind blocks.. I used the first solution and it's fine, as the VC has its own "loading" label. Thanks !
          – rdurand
          May 14 '13 at 15:25




          Thanks, I forgot for a second the logic behind blocks.. I used the first solution and it's fine, as the VC has its own "loading" label. Thanks !
          – rdurand
          May 14 '13 at 15:25




          1




          1




          @Matthias - any idea if it's possible to institute a timeout as well for the loadProductWithParameters call?
          – runamok
          Aug 6 '13 at 21:32




          @Matthias - any idea if it's possible to institute a timeout as well for the loadProductWithParameters call?
          – runamok
          Aug 6 '13 at 21:32




          1




          1




          One note - Apple says you should pass your store identifier as a NSNumber rather than a NSString.
          – Zack
          Jun 13 '14 at 19:44




          One note - Apple says you should pass your store identifier as a NSNumber rather than a NSString.
          – Zack
          Jun 13 '14 at 19:44












          You're right. I fixed it. Thanks
          – Matthias Bauch
          Jun 13 '14 at 20:55






          You're right. I fixed it. Thanks
          – Matthias Bauch
          Jun 13 '14 at 20:55














          My app got rejected in the App Store. This saved me.
          – vito.royeca
          Jun 21 '16 at 3:08




          My app got rejected in the App Store. This saved me.
          – vito.royeca
          Jun 21 '16 at 3:08


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f16546431%2fskstoreproductviewcontroller-showing-up-with-delay%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Costa Masnaga

          Fotorealismo

          Sidney Franklin