From 7d4ccf0f67f767d3955de45fd979fd0dfaaec7b7 Mon Sep 17 00:00:00 2001 From: Laurent Date: Mon, 9 Sep 2024 17:16:23 +0200 Subject: [PATCH] adds a way to see product ids in the interface --- .../xcshareddata/xcschemes/PadelClub.xcscheme | 2 +- .../Views/Navigation/Umpire/UmpireView.swift | 40 ++++++++++++++++++- .../Views/Tournament/Subscription/Guard.swift | 24 +++++++++-- 3 files changed, 61 insertions(+), 5 deletions(-) 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)