From 56affb3cb952666da4b5be140940901b2c1f876d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 6 Aug 2026 19:47:51 +0200 Subject: [PATCH] iOS: Don't resolve request ID 0 from the payment queue updatedTransactions posted success/failure unconditionally, but StoreKit also delivers transactions we didn't initiate - unfinished ones at startup, for instance - when no request is pending. Request IDs start at 10, so that just produced "Unexpected request ID 0" errors. Guard it like the restore-finished handler already does. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01JZk5y4Fzw811WJoNWZb8Sc --- ios/IAPManager.mm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ios/IAPManager.mm b/ios/IAPManager.mm index e48a6025e0..a3b0e587bc 100644 --- a/ios/IAPManager.mm +++ b/ios/IAPManager.mm @@ -134,15 +134,20 @@ // Perform the unlock (updaing the variable and switching the icon). [self unlockGold]; [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; - g_requestManager.PostSystemSuccess(_pendingRequestID, "", 0); - _pendingRequestID = 0; + // The queue also delivers transactions we didn't ask for, like unfinished ones at startup. + if (_pendingRequestID != 0) { + g_requestManager.PostSystemSuccess(_pendingRequestID, "", 0); + _pendingRequestID = 0; + } break; case SKPaymentTransactionStateFailed: NSLog(@"[IAPManager] Purchase failed (requestID: %d): %@", _pendingRequestID, transaction.error.localizedDescription); [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; // Optionally post failure callback here - g_requestManager.PostSystemFailure(_pendingRequestID); - _pendingRequestID = 0; + if (_pendingRequestID != 0) { + g_requestManager.PostSystemFailure(_pendingRequestID); + _pendingRequestID = 0; + } break; default: break;