5

Apple released the StoreKit and we cannot even get any callbacks for the cancel event when a user puts in his/her email and password for:

[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]

This event should not be confused with pushing cancel when cancelling a purchase.

The event we're interested in is pushing cancel when trying to restore transactions.

There are no callbacks for a user pushing cancel, or even pushing the OK button.

The only call back you get is when the information from the server comes back indicating if it was successful or not. Unacceptable.

pkamb
  • 33,281
  • 23
  • 160
  • 191
Joshua
  • 51
  • 1
  • 3

1 Answers1

12

Try this one:

@protocol SKPaymentTransactionObserver <NSObject>

....

@optional

// Sent when an error is encountered while adding transactions from the user's purchase history back to the queue.
- (void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);


@end
Adri
  • 530
  • 2
  • 8
  • 2
    If anyone wants to know how to tell the difference between a Cancel and a Connection problem from inside paymentQueue:restoreCompletedTransactionsFailedWithError:, then you should look at error.code. I've noticed that I get error code 2 when I cancel the restore, and error code -1009 when there is a connection problem during a restore. Both errors contain the same localized description: "Cannot connect to iTunes Store". I'm not sure of other error codes. What I do is end the request silently if it is code 2 and show a generic error message otherwise. – aiham Jul 04 '12 at 04:41
  • I have to add that it is unwise to check for the value 2, and it would be much safer to check for the error codes provided in http://developer.apple.com/library/ios/#documentation/StoreKit/Reference/StoreKitTypes/Reference/reference.html For cancels, you will need to compare the error code to SKErrorPaymentCancelled. – aiham Jul 04 '12 at 05:04
  • 1
    ...which happens to equal 2 right now (third index in an unnamed enum defined at ``), but of course that could change. Comparing against `SKErrorPaymentCancelled ` seems to be the wisest course of action. – Nicolas Miari Jul 18 '12 at 08:02
  • 1
    I'm getting error code 0 (`SKErrorUnknown`) on cancel. Posted new question here: http://stackoverflow.com/q/11537053/433373 – Nicolas Miari Jul 18 '12 at 08:40