Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect ErrorCode.productAlreadyPurchasedError when SKError.unknown is actually cased by it #965

Merged
merged 1 commit into from Nov 18, 2021

Conversation

NachoSoto
Copy link
Contributor

Fixes #392.

As per the conversation in that issue, this introspects and checks for the undocumented error domain and code.

Copy link
Contributor

@taquitos taquitos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎛 🐐

@@ -2112,6 +2112,45 @@ class PurchasesTests: XCTestCase {
expect(receivedUserCancelled).toEventually(beFalse())
}

func testUnknownErrorCurrentlySubscribedIsParsedCorrectly() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yessss tests are the bests

Comment on lines +243 to +248
case .unknown:
if let error = self.userInfo[NSUnderlyingErrorKey] as? NSError {
switch (error.domain, error.code) {
case ("ASDServerErrorDomain", 3532): // "You’re currently subscribed to this"
// See https://github.com/RevenueCat/purchases-ios/issues/392
return .productAlreadyPurchasedError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@NachoSoto NachoSoto merged commit b63daad into RevenueCat:main Nov 18, 2021
@NachoSoto NachoSoto deleted the already-purchased-error branch November 18, 2021 16:23
NachoSoto added a commit that referenced this pull request Dec 14, 2021
This allows us to handle unknown errors, like reported we did in #943, and provide a better user experience.
I filed FB9808927 for this issue in StoreKit 2. Unfortunately we can't do the same we did in #965.
NachoSoto added a commit that referenced this pull request Dec 15, 2021
This allows us to handle unknown errors, like reported we did in #943, and provide a better user experience.
I filed FB9808927 for this issue in StoreKit 2. Unfortunately we can't do the same we did in #965.
NachoSoto added a commit that referenced this pull request Dec 16, 2021
This allows us to handle unknown errors, like reported we did in #943, and provide a better user experience.
I filed FB9808927 for this issue in StoreKit 2. Unfortunately we can't do the same we did in #965 because the `StoreKitError` has no underlying information.

### Before:
<img width="372" alt="Screen Shot 2021-12-14 at 12 25 14" src="https://user-images.githubusercontent.com/685609/146079013-9073a170-d189-4cfc-b05a-d6c7e344b7cd.png">

### After:
<img width="372" alt="Screen Shot 2021-12-14 at 12 21 37" src="https://user-images.githubusercontent.com/685609/146078999-ce9387a8-f26f-43d2-b41c-f477de42a568.png">
NachoSoto added a commit that referenced this pull request Apr 5, 2022
…lations

Fixes #1445.
Similar solution to #965, this attempts to introspect the unknown `SKError` to detect if it actually corresponds to a failed purchase.
NachoSoto added a commit that referenced this pull request Apr 5, 2022
…lations (#1450)

Fixes #1445.
Similar solution to #965, this attempts to introspect the unknown `SKError` to detect if it actually corresponds to a failed purchase.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants