Hi,
We've been having a tricky problem with store kit. We are trying to implement correctly the in-app purchase renewable subscriptions process into an app that already is on the appStore with standard in-app purchase (non-consumable products) set up.
So far, and after spending 2 months fighting with the sandbox weird behavior, we came up with a working solution on a test iPad running iOS4.2.
Nasty surprise we got when testing this code on a iPad with 4.3 or 5.0, it does not have the same behavior.
We narrowed it down to this simple fact:
- iOS4.2 : the updatedTransactions callback is working properly
- iOS4.3 and above: the updatedTransactions callback is never called by the sandbox.
Any ideas on why a store kit code that works on iOS4.2 wouldn't work on following iOS versions? I didn't see anything deprecated on this.
Here is the code of our updatedTransactions code:
Thanks,
Stephane
We've been having a tricky problem with store kit. We are trying to implement correctly the in-app purchase renewable subscriptions process into an app that already is on the appStore with standard in-app purchase (non-consumable products) set up.
So far, and after spending 2 months fighting with the sandbox weird behavior, we came up with a working solution on a test iPad running iOS4.2.
Nasty surprise we got when testing this code on a iPad with 4.3 or 5.0, it does not have the same behavior.
We narrowed it down to this simple fact:
- iOS4.2 : the updatedTransactions callback is working properly
- iOS4.3 and above: the updatedTransactions callback is never called by the sandbox.
Any ideas on why a store kit code that works on iOS4.2 wouldn't work on following iOS versions? I didn't see anything deprecated on this.
Here is the code of our updatedTransactions code:
Code:
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
NSLog(@"Add payment queue");
for(SKPaymentTransaction *transaction in transactions) {
NSLog(@"Transaction state: %d, %d, %d, %d", transaction.transactionState, SKPaymentTransactionStatePurchased, SKPaymentTransactionStateFailed, SKPaymentTransactionStateRestored);
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchased:
if([transaction.payment.productIdentifier isEqualToString:FM_PRODUCT_IDENTIFIER_SUBSCRIPTION]){
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:transaction.transactionReceipt forKey:@"TransactionReceiptOfTransaction"];
}
[self completeTransaction:transaction];
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
break;
case SKPaymentTransactionStateFailed:
NSLog(@"%@", transaction.error);
[self failedTransaction:transaction];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", @"")
message:NSLocalizedString(@"Your subscription has expired.", @"")
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[alert show];
SAFE_RELEASE(alert);
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
if([transaction.error code] != SKErrorPaymentCancelled) {
if([transaction.payment.productIdentifier isEqualToString:FM_PRODUCT_IDENTIFIER_SUBSCRIPTION]){
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:transaction.transactionReceipt forKey:@"TransactionReceiptOfTransaction"];
}
}
break;
case SKPaymentTransactionStateRestored:
if([transaction.payment.productIdentifier isEqualToString:FM_PRODUCT_IDENTIFIER_SUBSCRIPTION]){
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:transaction.transactionReceipt forKey:@"TransactionReceiptOfTransaction"];
}
[self restoreTransaction:transaction];
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
default:
NSLog(@"Other");
break;
}
}
}
Thanks,
Stephane
Last edited by a moderator: