typealias ProductsRequestCompletion = (ProductsRequestResult) -> Void public class ProductsRequest: NSObject, SKProductsRequestDelegate { private var completion: ProductsRequestCompletion? private var request: SKProductsRequest init(_ productIDs: Set<String>) { self.request = SKProductsRequest(productIdentifiers: productIDs) } public func send(completion: @escaping ProductsRequestCompletion) { self.completion = completion self.request.delegate = self self.request.start() } public func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) { if let completion = completion { self.completion = nil completion(.success(response)) } } public func request(_ request: SKRequest, didFailWithError error: Error) { if let completion = completion { self.completion = nil completion(.failure(error)) } } } ɹɾdelegate method͕ݺΕΔεϨουอূ͞Ε͍ͯͳ͍
ɹɹ=>ϝΠϯεϨουͰݺΕΔલఏͰ͍Δͱ
ɹɹɹޙଓॲཧ͕Ϋϥογϡ͢Δ(iOS 13.1ʙ) ɹɾλΠϓ͕͔Βͳ͍
ɹɹ=>productIdentifierͷ໋໊ΛϧʔϧԽ͢Δɺରࡦ͕ඞཁ ɹɾใऔಘ͢Δ͚ͩͳͷʹ
ɹɹίʔυྔ͕ଟ͍(هࡌͷίʔυͰ࣮ࡍΓͳ͍)