Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In-App-Purchase takes too long time to show confirmation alert view

I have encountered the following issue: when my app runs on a device and I tap BUY button, which triggers In-App-Purchase mechanism it takes up to ten seconds to show the standard confirmation UIAlertView, the one which says: "Do you want to buy...". I have never seen such a behaviour before. Usually it happens immediately. So first I thought it might be due to poor internet connection or something like this, but the simulator uses the same WiFi network and it works perfectly, the alert view is presented instantly as it should be. So the problem probably lies somewhere else. Did anyone solve this issue already?

This is button click:

- (void)buyItemTapped:(id)sender
{
[[InAppPurchaseManager sharedInstance] buy:[NSString stringWithFormat:@"com.mycompany.myapp.unit%d", [sender tag] + 1]];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(transactionFailed)
                                             name:TRANSACTION_FAILED_NOTIFICATION
                                           object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(productPurchased:)
                                             name:PRODUCT_PURCHASED_NOTIFICATION
                                           object:nil];

}

buy method:

- (void)buy:(NSString *)identifier
{
SKProduct *product = [self.products objectForKey:identifier];

if (product)
   [self purchaseProduct:product];
else
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
                                                     message:@"Invalid Product Identifier"
                                                    delegate:nil
                                           cancelButtonTitle:@"OK"
                                           otherButtonTitles:nil];

    [alert show];

}
}

purchaseProduct method:

- (void)purchaseProduct:(SKProduct *)product
{
    if ([SKPaymentQueue canMakePayments])
{
    SKPayment *payment = [SKPayment paymentWithProduct:product];
    [[SKPaymentQueue defaultQueue] addPayment:payment];
 }
  else
      NSLog(@"Cannot make purchase");
}
like image 479
Andrey Chernukha Avatar asked Nov 08 '13 16:11

Andrey Chernukha


People also ask

How long does it take for an app purchase to process?

Normally an app will be reviewed and released in 24 hours, but there are so many things that come into play that can slow down the process.

How long does it take Apple to review in-app purchases?

On average, 90% of submissions are reviewed in less than 24 hours. You'll be notified by email of status changes. You can also check the review status of your submission in the My Apps section of App Store Connect or on the App Store Connect app for iPhone and iPad.

Why is an app purchase pending?

A pending purchase means that a user has purchased a product but does not complete the payment process. This purchase will stay in pending state until the payment process is completed within the specified duration.


1 Answers

This should have nothing to do with what an actual user experiences when they try to make the purchase. This is happening because you're running the app in the sandbox environment. In fact, using the simulator makes it even slower.

However, even when an actual user does make the purchase, the phone has to connect to Apple's servers, find the IAP, and then send the IAP data to the device securely. So, as you could imagine, it is normal that there is a little time before a confirmation message is sent back.

I recommend adding a loading screen in the SKPaymentTransactionStatePurchasing method, telling the user that you are in fact fetching the information. This could be as simple as changing the "Purchase" button to say "Purchasing...".

Again, this is 100% normal what you are seeing, but is mostly because you're using the sandbox and/or simulator. Apple has to do a lot of checks, and verify a lot of things before it can send back a confirmation message, so you should expect at least some minor delay (as if you were fetching information from a website).

like image 153
Jojodmo Avatar answered Oct 06 '22 00:10

Jojodmo