You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using this extension I found edge cases when this extension does not work properly. These are mainly “interrupted purchases”, see the following excerpt from Apple documentation:
It is important to add the observer at launch, in application(_:didFinishLaunchingWithOptions:), to ensure that it persists during all launches of your app, receives all payment queue notifications, and continues transactions that may be processed outside the app, such as:
It is clear from this documentation that this extension does not implement observers according the Apple guidance. Due to the nature of PromiseKit it is hard to come up with a solution which would fit.
Reproducing the issue
The thing is, SKPayment extension currently leaves some transactions unfinished. Even worse, the behavior is different on major iOS versions: 12 works fine and 13+ do not work. They notify about updated transactions at different times.
Steps:
During the purchase kill the app.
When you try to purchase the same product again it is either bought instantly or it fails and new dialog for buying is presented.
This ends in one unfinished transaction which is persisted during the runs of the app. When using purely this extension you will end up in inconsistent state.
It is not as obvious with non-consumable in-app purchases, but when using with subscriptions the issue becomes clearer.
My solution
In the end, I ended up using PromiseKit nevertheless, since it is extensively used in the app where I found this issue.
Firstly, I implemented this class to complete any unfinished transactions:
Secondly, I add this observer on application launch and remove it during StoreKit promise runs. Finishing transactions twice can end in an undefined behavior.
I either propose to update the documentation for this extension or provide guidance how to prevent others from running into this issue. As for now, I hope this issue will serve as some kind of documentation by itself.
TLDR Do not use this extension when working with auto-renewable subscriptions, because sooner or later one of your users will encounter an edge case when the transactions won't be completed properly.
The text was updated successfully, but these errors were encountered:
When using this extension I found edge cases when this extension does not work properly. These are mainly “interrupted purchases”, see the following excerpt from Apple documentation:
Source: https://developer.apple.com/documentation/storekit/in-app_purchase/setting_up_the_transaction_observer_for_the_payment_queue
It is clear from this documentation that this extension does not implement observers according the Apple guidance. Due to the nature of PromiseKit it is hard to come up with a solution which would fit.
Reproducing the issue
The thing is,
SKPayment
extension currently leaves some transactions unfinished. Even worse, the behavior is different on major iOS versions: 12 works fine and 13+ do not work. They notify about updated transactions at different times.Steps:
This ends in one unfinished transaction which is persisted during the runs of the app. When using purely this extension you will end up in inconsistent state.
It is not as obvious with non-consumable in-app purchases, but when using with subscriptions the issue becomes clearer.
My solution
In the end, I ended up using PromiseKit nevertheless, since it is extensively used in the app where I found this issue.
Firstly, I implemented this class to complete any unfinished transactions:
Secondly, I add this observer on application launch and remove it during StoreKit promise runs. Finishing transactions twice can end in an undefined behavior.
Next steps
I either propose to update the documentation for this extension or provide guidance how to prevent others from running into this issue. As for now, I hope this issue will serve as some kind of documentation by itself.
TLDR Do not use this extension when working with auto-renewable subscriptions, because sooner or later one of your users will encounter an edge case when the transactions won't be completed properly.
The text was updated successfully, but these errors were encountered: