We have implemented the redemption of offer codes using the function
SKPaymentQueue.default().presentCodeRedemptionSheet()
the modal appears correctly and the flow ends successfully, we receive the callback from apple on the server side, the problem is that we do not receive feedback on the app side and we cannot guarantee a good user experience. in particular it seems that the function
paymentQueue (_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction])
is not called, but we are not sure because we can't find a way to test it.
The standard app purchase flow works fine, but code redemption does not.
In general it is very difficult to test these discount codes because they are only testable with the app in production, without being able to take advantage of the debug prints or breakpoints. In addition, a particular offer can only be redeemed once per apple id
Is there any way to test offer codes in debug mode?
How could we do some tests on the code without sending the app for verification every time?
Thanks
Here's my workflow based on my assumption, and it worked well when I first wrote this answer.

Sadly, as @mota mentioned, in this situation, in iOS 15.4 willResignActiveNotification followed by didBecomeActiveNotification immediately, which broke my assumption.
When StoreKit presents the CodeRedemptionSheet, UIKit will call applicationWillResignActive.
And when I click the cancel button or swipe it off, UIKit will call applicationDidBecomeActive.
Maybe you can use this feature to catch its status.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With