I found a new transient bug in StoreKit. The receipt was not installed before the call to updatedTransactions after a restoreCompletedTransaction. This happened about 4 times and then the problem disappeared. Go figure. Anyone else missing an expected receipt? Should I leave the delay in the code?
Here is the 'proof' it was a real bug. 3 times without the delay I got the NSLog message "no receipt". 3 times with the .01 second delay it worked. After the last time it failed without the delay it started working with or without the delay:
// in updatedTransactions:
case SKPaymentTransactionStateRestored:
if([productIdentifiers1 containsObject:transaction.payment.productIdentifier]){
status=@"restored";
// comment out one of the next two lines:
[self checkReceipt];
// [self performSelector:@selector(checkReceipt) withObject:nil afterDelay:0.01f];
// remainder of code
-(void)checkReceipt{
NSDictionary *receiptDict=[self theReceipt];
// rest of method
-(NSDictionary *)theReceipt{
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receiptData=[NSData dataWithContentsOfURL:receiptURL];
if(!receiptData)
NSLog(@"no receipt");
//// rest of method