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
Conversation
… actually caused by it Fixes RevenueCat#392.
There was a problem hiding this 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() { |
There was a problem hiding this comment.
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
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
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">
Fixes #392.
As per the conversation in that issue, this introspects and checks for the undocumented error domain and code.