I have set up a store kit 2 iOS in-app purchase system in Swift, and I have a transaction listener. The listener is supposed to listen for any updates that occur outside the app. However, I need to determine if an update in the listener is for an actual purchase or something like a revocation or expiration. I need to filter out these updates because I make an API request to update my database in the backend when a purchase is successful. Unfortunately, I’ve noticed that the listener is called whenever I disable or enable auto-renewal.
I am calling the API update in listener to listen to pending purchase success if a purchase was initiated but pending due to parent approval or bank approval.
Here is some pseudo code of my implementation
for await verificationResult in Transaction.updates {
switch verificationResult {
case .verified(let transaction):
// Issue: don't make API call anytime there is update. Filter to see if this call is for an actual purchase and not something like auto renewal state change.
await makeAPICall()
await transaction.finish()
}