I am developing an application in which user can purchase auto-renewable subscription. Buying part is woking alright but problem occurs when user deletes the application and tries to restore his purchases. following is the code I wrote to handle that.
I have given a button titled "Already a Subscriber". When user tap that I call following code.
[[SKPaymentQueue defaultQueue] addTransactionObserver:self]; [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
And this is how I handle restore in
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
method.case SKPaymentTransactionStateRestored: duration = [strDuration intValue]; if(transaction.transactionReceipt != nil){ receipt = [[NSString alloc] initWithData:[b64 dataByBase64EncodeFromData:transaction.transactionReceipt] encoding:NSASCIIStringEncoding]; [userDefault setObject:transaction.transactionReceipt forKey:@"LastReceipt"]; [queue finishTransaction:transaction]; [self callReceiptInfoImpl]; } break;
Following is delegate method when restore transaction is completed.
-(void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue{ NSLog(@"COMPLETED TRANSACTION RESTORED"); }
Problem is that, when user clicks button "Already a subscriber" then Step 1. gets called but Step 2. never gets called. Finally I can see message "COMPLETED TRANSACTION RESTORED" on screen.
If anybody has faced similar problem then please guide.
Thanks for reading.....