Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-productRequest:didReceiveResponse returns empty products array in real store, works in sandbox

I recently had an update to an app approved. This versioned added In app purchases. The app works perfect in sandbox mode and Apple did approve both the IAP and the app, but the in app purchases fails in the app.

I think the crash occurs because the response.products from:

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
}

returns an empty array and that:

SKProduct *product = [[products filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"productIdentifier == %@", _model.packageId]] firstObject];

returns nil. I can't get the price of the SKProduct. I think that the actual app crash is with these lines since product and payment probably is nil.

SKPayment *payment = [SKPayment paymentWithProduct:product];
[[SKPaymentQueue defaultQueue] addPayment:payment];

I read other blog posts that it can take up to 24 hours before IAP becomes available. Is this true? Do I need to worry about bugs regarding the IAP's in my app when it works in sandbox mode and that Apple approved it?

like image 589
Johan Nordberg Avatar asked Oct 01 '22 16:10

Johan Nordberg


1 Answers

It turned out that this is indeed an Apple problem. I got a response from Apple stating that it can take up to 36 hours before the In App Purchases is available.

I guess this makes it really important to handle the case when

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
}

is called, but when response.products is empty. When you try to get the actual product, make sure that you don't get a nil result.

I wish that Apple would not approve and release an update of an app until the IAP was really ready for sale.

like image 128
Johan Nordberg Avatar answered Oct 27 '22 10:10

Johan Nordberg