I'm using the latest MKStoreKit to make an in-app purchase. The problem I've ran into is that when the app doesn't have internet when it starts, the products aren't loaded from the app store. If I then run
- (void) buyFeature:(NSString*) featureId
onComplete:(void (^)(NSString* purchasedFeature, NSData*purchasedReceipt)) completionBlock
onCancelled:(void (^)(void)) cancelBlock;
Then it never runs either of onComplete or onCancelled because it returns here when it doesn't find the purchasable object.
NSArray *allIds = [self.purchasableObjects valueForKey:@"productIdentifier"];
int index = [allIds indexOfObject:productId];
if(index == NSNotFound) return; <-- IT RETURNS HERE
SKProduct *thisProduct = [self.purchasableObjects objectAtIndex:index];
SKPayment *payment = [SKPayment paymentWithProduct:thisProduct];
[[SKPaymentQueue defaultQueue] addPayment:payment];
It doesn't even send back an error so the user doesn't get any message.
I guess this should be a common problem? How do I handle it in the best way?