Check if user cancelled SKPaymentTransaction
Ellen's answer is perfect. Just in case someone is wondering about the other cases
switch (transaction.error.code) {
case SKErrorUnknown:
//Unknown error
break;
case SKErrorClientInvalid:
// client is not allowed to issue the request, etc.
break;
case SKErrorPaymentCancelled:
// user cancelled the request, etc.
break;
case SKErrorPaymentInvalid:
// purchase identifier was invalid, etc.
break;
case SKErrorPaymentNotAllowed:
// this device is not allowed to make the payment
break;
default:
break;
}
This code works for me:
if (transaction.error.code != SKErrorPaymentCancelled) {
NSLog(@"Other error");
} else {
NSLog(@"User canceled");
}