Created
June 18, 2019 09:44
-
-
Save ren6/653e4f391da21fd486021266340673be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Starts products loading and sets transaction observer delegate | |
@objc func startWith(arrayOfIds : Set<String>!, sharedSecret : String){ | |
SKPaymentQueue.default().add(self) | |
self.sharedSecret = sharedSecret | |
self.productIds = arrayOfIds | |
loadProducts() | |
} | |
private func loadProducts(){ | |
let request = SKProductsRequest.init(productIdentifiers: productIds) | |
request.delegate = self | |
request.start() | |
} | |
public func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) { | |
products = response.products | |
DispatchQueue.main.async { | |
NotificationCenter.default.post(name: IAP_PRODUCTS_DID_LOAD_NOTIFICATION, object: nil) | |
} | |
} | |
func request(_ request: SKRequest, didFailWithError error: Error){ | |
print("error: \(error.localizedDescription)") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment