Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reasons for SKProductsRequest returning 0 products?

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:

  • Test product has been added to iTunes connect
  • The product's bundle id matches the app bundle id (and its not using a wildcard)
  • The product identifier set in the SKProductRequest matches the product created on iTunes connect
  • I've waited several hours since the product was created on iTunes connect
  • The provisioning profiles enable IAP
  • Followed all steps in various tutorial such as http://troybrant.net/blog/2010/01/in-app-purchases-a-full-walkthrough/ etc.
  • Have deleted app from device, relaunched Xcode, rebuilt etc. etc.

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);     } } 
like image 653
Gruntcakes Avatar asked Jan 28 '14 00:01

Gruntcakes


1 Answers

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 enter image description here 2) iTunes Connect -> Agreements, Tax, and Banking -> Master Agreements -> Paid Applications-> Contact Info / Bank Info / Tax Info (should be filled)enter image description here 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)         }      } } 

like image 172
Ivan Besarab Avatar answered Sep 29 '22 06:09

Ivan Besarab