Add check before listing products

This commit is contained in:
Davide De Rosa 2020-05-13 14:23:21 +02:00
parent a694ea7309
commit 81fcb923b4
1 changed files with 7 additions and 2 deletions

View File

@ -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)