-
Notifications
You must be signed in to change notification settings - Fork 795
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
Calling purchaseProduct
quickly after retrieveProductsInfo
invlaidates latter's completion handler
#250
Comments
I would not recommend calling The README shows the recommended way: https://github.com/bizz84/SwiftyStoreKit#purchase-a-product-given-a-skproduct SwiftyStoreKit.retrieveProductsInfo(["com.musevisions.SwiftyStoreKit.Purchase1"]) { result in
if let product = result.retrievedProducts.first {
SwiftyStoreKit.purchaseProduct(product, quantity: 1, atomically: true) { result in
// handle result (same as above)
}
}
} |
I understand that is the recommended way and I have since abandoned my way of handling things. That being said, a completion handler not getting called ever is definitely a bug which can have some sever consequences. I would not just want to sweep this one under the rug. |
@gapl You are correct. This is a bug in I can see two ways of fixing this:
I started #259 to solve this with the more efficient way. Once I'm satisfied that it works correctly and I have unit tests for this I can merge it. If you have any feedback on this proposal, please let me know. |
@bizz84 Props for tackling this issue. I've checked out your branch briefly and the approach seems solid. One possible enhancement would be to not remove the request upon successful completion as you could cache it for the duration of the session. No need to re-fire an already successful product fetch. Only thing to watch out would be to remove the request in case it errors out or is cancelled. |
@gapl See related issue #212. Caching products can lead to undesired problems where a fetched product becomes outdated if the corresponding IAP is modified on iTunes Connect. I think it's reasonable to "merge" together requests that are concurrent. However, once a response is received SwiftyStoreKit will just return it and clear all temporary state. If clients wish to do so, they can hold to the products for a longer time. |
Oh, makes sense. I was not aware of those implications. 👍 |
This is now fixed and available on version 0.10.7, so I'm closing this issue. If you experience any issues with this, feel free to reopen. |
Platform
In app purchase type
Environment
Version
v0.10.4
Related issues
Couldn't find any.
Report
Issue summary
Completion handler of
retrieveProductsInfo
never gets called if we quickly callpurchaseProduct
afterwards.Very easy to reproduce:
What did you expect to happen
That
retrieveProductsInfo
completion handler gets called regardless.What happened instead
Completion handler is never invoked.
The text was updated successfully, but these errors were encountered: