Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

kMKStoreKitProductPurchaseFailedNotification doesn't contain the error object. It's required to determine whether the user pressed Cancel (error.code == SKErrorPaymentCancelled) #246

Open
funnel20 opened this issue Sep 21, 2015 · 0 comments

Comments

@funnel20
Copy link

On an error I'd like to show an Alert to the user.
However, when he presses cancel on one of the App Store Alerts (like entering App Store credentials), this kMKStoreKitProductPurchaseFailedNotification is also send.
If he presses Cancel I don't want to show an Alert.
In other words I need to now the error code.

To do so, I changed the following line:

[[NSNotificationCenter defaultCenter] postNotificationName:kMKStoreKitProductPurchaseFailedNotification
                                                      object:transaction.payment.productIdentifier];

in:

[[NSNotificationCenter defaultCenter] postNotificationName:kMKStoreKitProductPurchaseFailedNotification
                                                      object:transaction];

by using the complete SKPaymentTransaction as object.

When receiving the notification in a class, the transaction ID can be retrieved via:

SKPaymentTransaction *transaction = [notification object];
NSString *id = transaction.payment.productIdentifier;

And the error code via:

NSInteger code = transaction.error.code;

The latter can be compared to SKErrorPaymentCancelled.

@funnel20 funnel20 changed the title kMKStoreKitProductPurchaseFailedNotification doesn't contain the error object. Is required to determine whether the user pressed Cancel (error.code == SKErrorPaymentCancelled) kMKStoreKitProductPurchaseFailedNotification doesn't contain the error object. It's required to determine whether the user pressed Cancel (error.code == SKErrorPaymentCancelled) Sep 21, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant