From 9566bac598167fc79324a54a077e28662267c72b Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Thu, 4 Feb 2021 11:32:21 +0100 Subject: [PATCH] Fix bad callback thread in restore purchases --- Passepartout/Core/Sources/Model/ProductManager.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Passepartout/Core/Sources/Model/ProductManager.swift b/Passepartout/Core/Sources/Model/ProductManager.swift index ac71e0ca..601d54a6 100644 --- a/Passepartout/Core/Sources/Model/ProductManager.swift +++ b/Passepartout/Core/Sources/Model/ProductManager.swift @@ -294,14 +294,18 @@ extension ProductManager: SKRequestDelegate { guard finished else { return } - self?.restoreCompletionHandler?(error) - self?.restoreCompletionHandler = nil + DispatchQueue.main.async { + self?.restoreCompletionHandler?(error) + self?.restoreCompletionHandler = nil + } } } public func request(_ request: SKRequest, didFailWithError error: Error) { - restoreCompletionHandler?(error) - restoreCompletionHandler = nil + DispatchQueue.main.async { [weak self] in + self?.restoreCompletionHandler?(error) + self?.restoreCompletionHandler = nil + } } }