From 81fcb923b4715eac5522067b761f0be5b950ba52 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Wed, 13 May 2020 14:23:21 +0200 Subject: [PATCH] Add check before listing products --- Passepartout-iOS/Global/ProductManager.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Passepartout-iOS/Global/ProductManager.swift b/Passepartout-iOS/Global/ProductManager.swift index b4e5cf32..483c9536 100644 --- a/Passepartout-iOS/Global/ProductManager.swift +++ b/Passepartout-iOS/Global/ProductManager.swift @@ -67,9 +67,14 @@ class ProductManager: NSObject { } func listProducts(completionHandler: (([SKProduct]?, Error?) -> Void)?) { - inApp.requestProducts(withIdentifiers: Product.all, completionHandler: { _ in + let products = Product.all + guard !products.isEmpty else { + completionHandler?(nil, nil) + return + } + inApp.requestProducts(withIdentifiers: products, completionHandler: { _ in log.debug("In-app products: \(self.inApp.products.map { $0.productIdentifier })") - + completionHandler?(self.inApp.products, nil) }, failureHandler: { completionHandler?(nil, $0)