Skip to content
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

StoreKit1Wrapper: added debug log when transaction is removed but no callbacks to notify #2418

Merged
merged 1 commit into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Sources/Logging/Strings/PurchaseStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ enum PurchaseStrings {
case finishing_transaction(StoreTransactionType)
case purchasing_with_observer_mode_and_finish_transactions_false_warning
case paymentqueue_revoked_entitlements_for_product_identifiers(productIdentifiers: [String])
case paymentqueue_removed_transaction(_ observer: SKPaymentTransactionObserver,
_ transaction: SKPaymentTransaction)
case paymentqueue_updated_transaction(_ observer: SKPaymentTransactionObserver,
_ transaction: SKPaymentTransaction)
case paymentqueue_removed_transaction(SKPaymentTransactionObserver,
SKPaymentTransaction)
case paymentqueue_removed_transaction_no_callbacks_found(SKPaymentTransactionObserver,
SKPaymentTransaction)
case paymentqueue_updated_transaction(SKPaymentTransactionObserver,
SKPaymentTransaction)
case presenting_code_redemption_sheet
case unable_to_present_redemption_sheet
case purchases_synced
Expand Down Expand Up @@ -131,6 +133,10 @@ extension PurchaseStrings: CustomStringConvertible {
.compactMap { $0 }
.joined(separator: " ")

case let .paymentqueue_removed_transaction_no_callbacks_found(observer, transaction):
return "\(observer.debugName) removedTransaction for (\(transaction.payment.productIdentifier) " +
"but not callbacks to notify"

case let .paymentqueue_updated_transaction(observer, transaction):
return "\(observer.debugName) updatedTransaction: \(transaction.payment.productIdentifier) " +
[
Expand Down
6 changes: 5 additions & 1 deletion Sources/Purchasing/StoreKit1/StoreKit1Wrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,12 @@ extension StoreKit1Wrapper: SKPaymentTransactionObserver {
Logger.debug(Strings.purchase.paymentqueue_removed_transaction(self, transaction))
delegate.storeKit1Wrapper(self, removedTransaction: transaction)

if let callbacks = self.finishedTransactionCallbacks.value.removeValue(forKey: transaction) {
if let callbacks = self.finishedTransactionCallbacks.value.removeValue(forKey: transaction),
!callbacks.isEmpty {
callbacks.forEach { $0() }
} else {
Logger.debug(Strings.purchase.paymentqueue_removed_transaction_no_callbacks_found(self,
transaction))
}
}
}
Expand Down