diff --git a/PadelClub.xcodeproj/xcshareddata/xcschemes/PadelClub.xcscheme b/PadelClub.xcodeproj/xcshareddata/xcschemes/PadelClub.xcscheme index b4b5279..d92da1f 100644 --- a/PadelClub.xcodeproj/xcshareddata/xcschemes/PadelClub.xcscheme +++ b/PadelClub.xcodeproj/xcshareddata/xcschemes/PadelClub.xcscheme @@ -74,7 +74,7 @@ + identifier = "../PadelClub/SyncedProducts.storekit"> ? = nil + var updateListenerTask: Task? = nil fileprivate(set) var purchases: StoredCollection @@ -39,6 +39,23 @@ import LeStorage } } + deinit { + self.updateListenerTask?.cancel() + } + + func productIds() async -> [String] { + var productIds: [String] = [] + for await result in Transaction.all { + do { + let verified = try self.checkVerified(result) + productIds.append(verified.productID) + } catch { + Logger.error(error) + } + } + return productIds + } + func refreshPurchasedAppleProducts() async throws { // Iterate through the user's purchased products. @@ -51,10 +68,11 @@ import LeStorage } } - func listenForTransactions() -> Task { - return Task.detached { + func listenForTransactions() -> Task { + return Task(priority: .background) { //Iterate through any transactions which didn't come from a direct call to `purchase()`. for await result in Transaction.updates { + Logger.log(">>> update = \(result)") do { let transaction = try self.checkVerified(result)