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 my checklist:
Any other suggestions as to why the fetched product count is zero?
I don't believe this will be a coding issue, but here it is anyway:
… NSSet *productIdentifiers = [NSSet setWithObjects:@"redacted", nil]; self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers]; self.productsRequest.delegate = self; [self.productsRequest start]; … - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response { NSArray *products = response.products; NSLog(@"Product count: %d", [products count]); for (SKProduct *product in products) { NSLog(@"Product: %@ %@ %f", product.productIdentifier, product.localizedTitle, product.price.floatValue); } }
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) } } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With