应用内购中途取消返回SKErrorDomain Code=2,咨询苹果官方相关文档
Hey fellow developer, let me break this down clearly for you—this is a super common StoreKit error I’ve dealt with countless times!
First off, SKErrorDomain Code=2 directly maps to SKErrorPaymentCancelled in the StoreKit framework. This error is triggered exactly when the user actively cancels the in-app purchase flow—think tapping the "Cancel" button on the Apple ID authentication sheet, or backing out of the payment confirmation dialog.
And yes, Apple absolutely has official documentation covering this! In Apple’s StoreKit reference docs, the SKError enumeration explicitly lists this error code as representing a user-initiated cancellation. It’s categorized as an expected, non-failure scenario—this isn’t a bug in your app or a system error, just the user choosing to abort the purchase.
A quick tip for handling this: You usually don’t need to show an error alert to the user here, since they chose to cancel. Instead, you can just log the event for your own analytics and return the user to the normal app flow seamlessly.
内容的提问来源于stack exchange,提问作者wes. i

