I've configured IAP for my project and It seems to work, so my app is live on app store but I've discovered that approximately 30% requests to iTunes returning invalidProductIdentifier for some reason, below is the complete code:
class IAP: NSObject, SKProductsRequestDelegate {
static let sharedInstance = IAP()
func productsRequest(request: SKProductsRequest, didReceiveResponse response: SKProductsResponse) {
response.invalidProductIdentifiers.forEach() { id in
//here is the part that could fail sometimes
print(id)
}
}
//here how I setup IAP
func canMakePayments() {
if(SKPaymentQueue.canMakePayments()) {
var productID = NSSet()
productID = NSSet(object: "unlock")
let request: SKProductsRequest = SKProductsRequest(productIdentifiers: productID as! Set<String>)
request.delegate = self
request.start()
}
}
}
And here how I use it from AppDelegate
:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
IAP.sharedInstance.canMakePayments()
return true
}