From 83b6adbf863e1118ddcf10e665f3f7de96026851 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Tue, 20 Jul 2021 00:21:14 +0200 Subject: [PATCH] Fix crash on in-app purchase Concurrency issue. Purchase is however credited after app relaunch. --- Passepartout/App/macOS/CHANGELOG.md | 3 ++- .../Core/Sources/Model/ProductManager.swift | 8 ++++-- Podfile | 4 +-- Podfile.lock | 26 +++++++++---------- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/Passepartout/App/macOS/CHANGELOG.md b/Passepartout/App/macOS/CHANGELOG.md index 42261098..5c4962c8 100644 --- a/Passepartout/App/macOS/CHANGELOG.md +++ b/Passepartout/App/macOS/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## 1.15.3 Beta 2669 (2021-07-16) +## Unreleased ### Added @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Crash when adding dynamically updated provider. +- In-app purchases might crash the app and not be credited until relaunch. ## 1.15.2 (2021-04-17) diff --git a/Passepartout/Core/Sources/Model/ProductManager.swift b/Passepartout/Core/Sources/Model/ProductManager.swift index 62e54dd7..4839735c 100644 --- a/Passepartout/Core/Sources/Model/ProductManager.swift +++ b/Passepartout/Core/Sources/Model/ProductManager.swift @@ -298,13 +298,17 @@ public class ProductManager: NSObject { extension ProductManager: SKPaymentTransactionObserver { public func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) { - reloadReceipt() + DispatchQueue.main.async { [weak self] in + self?.reloadReceipt() + } } } extension ProductManager: SKRequestDelegate { public func requestDidFinish(_ request: SKRequest) { - reloadReceipt() + DispatchQueue.main.async { [weak self] in + self?.reloadReceipt() + } inApp.restorePurchases { [weak self] (finished, _, error) in guard finished else { return diff --git a/Podfile b/Podfile index 5fbb148a..00b1b4bb 100644 --- a/Podfile +++ b/Podfile @@ -16,13 +16,13 @@ end def shared_pods_ios shared_pods for spec in ['About', 'Alerts', 'Dialogs', 'InApp', 'Misc', 'Options', 'Persistence', 'Reviewer', 'Tables', 'WebServices'] do - pod "Convenience/#{spec}", :git => 'https://github.com/keeshux/convenience', :commit => 'b30816a' + pod "Convenience/#{spec}", :git => 'https://github.com/keeshux/convenience', :commit => '5ed1fe0' end end def shared_pods_macos shared_pods for spec in ['InApp', 'Misc', 'Persistence', 'Reviewer', 'WebServices'] do - pod "Convenience/#{spec}", :git => 'https://github.com/keeshux/convenience', :commit => 'b30816a' + pod "Convenience/#{spec}", :git => 'https://github.com/keeshux/convenience', :commit => '5ed1fe0' end end diff --git a/Podfile.lock b/Podfile.lock index 9e84adf7..86abc73f 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -39,16 +39,16 @@ PODS: - TunnelKit/Manager DEPENDENCIES: - - Convenience/About (from `https://github.com/keeshux/convenience`, commit `b30816a`) - - Convenience/Alerts (from `https://github.com/keeshux/convenience`, commit `b30816a`) - - Convenience/Dialogs (from `https://github.com/keeshux/convenience`, commit `b30816a`) - - Convenience/InApp (from `https://github.com/keeshux/convenience`, commit `b30816a`) - - Convenience/Misc (from `https://github.com/keeshux/convenience`, commit `b30816a`) - - Convenience/Options (from `https://github.com/keeshux/convenience`, commit `b30816a`) - - Convenience/Persistence (from `https://github.com/keeshux/convenience`, commit `b30816a`) - - Convenience/Reviewer (from `https://github.com/keeshux/convenience`, commit `b30816a`) - - Convenience/Tables (from `https://github.com/keeshux/convenience`, commit `b30816a`) - - Convenience/WebServices (from `https://github.com/keeshux/convenience`, commit `b30816a`) + - Convenience/About (from `https://github.com/keeshux/convenience`, commit `5ed1fe0`) + - Convenience/Alerts (from `https://github.com/keeshux/convenience`, commit `5ed1fe0`) + - Convenience/Dialogs (from `https://github.com/keeshux/convenience`, commit `5ed1fe0`) + - Convenience/InApp (from `https://github.com/keeshux/convenience`, commit `5ed1fe0`) + - Convenience/Misc (from `https://github.com/keeshux/convenience`, commit `5ed1fe0`) + - Convenience/Options (from `https://github.com/keeshux/convenience`, commit `5ed1fe0`) + - Convenience/Persistence (from `https://github.com/keeshux/convenience`, commit `5ed1fe0`) + - Convenience/Reviewer (from `https://github.com/keeshux/convenience`, commit `5ed1fe0`) + - Convenience/Tables (from `https://github.com/keeshux/convenience`, commit `5ed1fe0`) + - Convenience/WebServices (from `https://github.com/keeshux/convenience`, commit `5ed1fe0`) - Kvitto - MBProgressHUD - SSZipArchive @@ -67,12 +67,12 @@ SPEC REPOS: EXTERNAL SOURCES: Convenience: - :commit: b30816a + :commit: 5ed1fe0 :git: https://github.com/keeshux/convenience CHECKOUT OPTIONS: Convenience: - :commit: b30816a + :commit: 5ed1fe0 :git: https://github.com/keeshux/convenience SPEC CHECKSUMS: @@ -85,6 +85,6 @@ SPEC CHECKSUMS: SwiftyBeaver: 84069991dd5dca07d7069100985badaca7f0ce82 TunnelKit: 068ff24480fa0f10e2209f3e9a75cfed9b4d78ec -PODFILE CHECKSUM: 1ee335adb14f0e5517ddeed41e8bed5b0de59ec9 +PODFILE CHECKSUM: f88917df911decd28e1ada0b866f3370fb4ae70e COCOAPODS: 1.10.1