Reasons for SKProductsRequest returning 0 products?
Solution 1:
Check all 3 things in the list below
1) check your product identifiers - they must be exactly the same that you have in your code and in iTunes Connect -> My Apps -> YourAppName -> Features -> In-App Purchases
2) iTunes Connect -> Agreements, Tax, and Banking -> Master Agreements -> Paid Applications-> Contact Info / Bank Info / Tax Info (should be filled)
3) code to test it
class ViewController: UIViewController {
var requestProd = SKProductsRequest()
var products = [SKProduct]()
override func viewDidLoad() {
super.viewDidLoad()
validateProductIdentifiers()
}
}
extension ViewController: SKProductsRequestDelegate {
func validateProductIdentifiers() {
let productsRequest = SKProductsRequest(productIdentifiers: Set(["candy100", "someOtherProductId"]))
// Keep a strong reference to the request.
self.requestProd = productsRequest;
productsRequest.delegate = self
productsRequest.start()
}
// SKProductsRequestDelegate protocol method
public func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
self.products = response.products
for invalidIdentifier in response.invalidProductIdentifiers {
print(invalidIdentifier)
}
}
}
Solution 2:
Make sure you have In-App Purchase turned on in the Capabilities section. If you don't, SKProductsRequest will return 0 products.
Solution 3:
I was facing the same problem, Solved it by sending just the IAP Product name rather than my bundle id before the product name. Here is the example :
works
SKProductsRequest *productRequest = [[SKProductsRequest alloc]initWithProductIdentifiers:[NSSet setWithObject:@"my_product"]];
rather than
doesn't work
SKProductsRequest *productRequest = [[SKProductsRequest alloc]initWithProductIdentifiers:[NSSet setWithObject:@"com.my_site.my_app.my_product"]];
Solution 4:
I had the same issue...
I simply change my bundle identifier which does not match with an iTunes bundle identifier.
And my app runs well :)
Solution 5:
In the off chance that you've overlooked this, the product identifier match is case sensitive.
So, if you've created a product on Apple with an identifier of say
com.yourcompany.product1
and you call the product request with a product identifier of
com.yourcompany.Product1
Your list will be returned with zero products.
This kept me busy for a while :-)
ps: On a separate project, I found SKProductsRequest only started returning products after a restart. So, if all else fails, try restarting your Mac.