|
|
|
|
@ -18,7 +18,7 @@ import LeStorage |
|
|
|
|
|
|
|
|
|
var currentBestPlan: StoreKit.Transaction? = nil |
|
|
|
|
|
|
|
|
|
var updateListenerTask: Task<Void, Error>? = nil |
|
|
|
|
var updateListenerTask: Task<Void, Never>? = nil |
|
|
|
|
|
|
|
|
|
fileprivate(set) var purchases: StoredCollection<Purchase> |
|
|
|
|
|
|
|
|
|
@ -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<Void, Error> { |
|
|
|
|
return Task.detached { |
|
|
|
|
func listenForTransactions() -> Task<Void, Never> { |
|
|
|
|
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) |
|
|
|
|
|
|
|
|
|
|