I\'m trying to set up IAP but after making a call to retrieve the products using SKProductsRequest the SKProductsResponse array within my delegate has a count of 0. Here\'s
IN swift 5, I am facing the same problem getting Skproducts count 0. I solved this Goto iTunes Connect -> Agreements and Tax if status is New there then there should be term view button besides status click it fill the complete form and then the paid apps will be shown status active and Skproducts counts would be visible in xcode console.
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)
}
}
}
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"]];
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.
Initial answer
Have you got your contract, banks, etc info setup?
Corrected answer
It seems I'm wrong about this. Take a look at In-App Purchase, SKProductsRequest returning 0 - Products still in Review
Also, keep in mind that agreeing to the Paid Applications cotract is not enough. You also have to fill out the contact, bank and tax information for that agreemant specifically, for it to be considered done.