I'm working on an App like Lovoo. So I want to implement consumable and non-consumable IAPs. After I buy a product I request the receipt from NSBundle.mainBundle().appStoreReceiptURL. I upload it to my server and PHP verifies it with the Apple server. Then my server gives a responst to my App with the number of credits the user owns now. The problem is, I only get old receipts from the Apple server which are several days old. So when I buy a product, I activate the products I bought yesterday but not the one I bought right now. How can I get the current receipt from the Apple server to provide the content?
You get the current receipt by
SKReceiptRefreshRequest *request=[[SKReceiptRefreshRequest alloc] init];
[request setDelegate:self];
[request start];
-(void)requestDidFinish:(SKRequest *)request{
if([request isKindOfClass:[SKReceiptRefreshRequest class]] ){
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
if([[NSFileManager defaultManager] fileExistsAtPath:receiptURL.path]){
[self testTheReceipt];
}else{
UIAlertView *noReceipt;
noReceipt = [[UIAlertView alloc]
initWithTitle:nil
message:@"It appears that your app does not have a receipt. This purchase cannot be verified."
delegate: nil
cancelButtonTitle:@"Sorry"
otherButtonTitles:nil ] ;
[noReceipt show];
}
}
}
But you should already have a refreshed receipt when StoreKit calls
-(void) paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{