Reputation: 552
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
}
Upvotes: 18
Views: 686
Reputation: 1029
If you have appstore version of that application in your test device and you are trying to debug that IAP on same device, this may cause this. Please un-install apstore version of app before trying anything. Second possible problem is, you should check IAP with USB cable plugged in. You cant test it with Ad-hoc deployment.
Also I found a great link to check all possible failures:
http://troybrant.net/blog/2010/01/invalid-product-ids/
Upvotes: 1
Reputation: 339
If you receive invalidProductIdentifiers on your test device there may be tons of reasons why this happens. The most frequent cases are:
You can find more reasons here. Nevertheless invalid product IDs issue on test device doesn't necessary mean that your users experience that problem too.
Upvotes: 2