2
votes

So I follow tutorial and try to make a test app with IAP.

1) I created new App ID

2) Added two consumable products with ID iapdemo_extra_colors_colect_1 and iapdemo_extra_colors_colect_2"

3) Created test user in iTunes connect

4) Created and App.

5) Made separate page for purchases with tableView view

6) Copied App ID bundle id to info.plist to "Bundle identifier"

7) And my purchase page code is :

import UIKit
import StoreKit

class IAPurchaceViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, SKProductsRequestDelegate {


  var productIDs: [String!] = []

  var productsArray: [SKProduct!] = []

    @IBOutlet weak var tblProducts: UITableView!

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.


        tblProducts.delegate = self
        tblProducts.dataSource = self

      productIDs.append("iapdemo_extra_colors_colect_1")
      productIDs.append("iapdemo_extra_colors_colect_2")

      requestProductInfo()
    }

  func requestProductInfo() {

    if SKPaymentQueue.canMakePayments() {
      let productIdentifiers = NSSet(array: productIDs)
      let productRequest = SKProductsRequest(productIdentifiers: productIdentifiers as! Set<String>)

      productRequest.delegate = self
      productRequest.start()
    } else {
      print("Cannot perform In App Purchases.")
    }
  }


  func productsRequest(request: SKProductsRequest, didReceiveResponse response: SKProductsResponse) {
    if response.products.count != 0 {
      for product in response.products {
        productsArray.append(product )
      }

      tblProducts.reloadData()
    } else {
      print("There are no products.")
    }

    if response.invalidProductIdentifiers.count != 0 {
      print(response.invalidProductIdentifiers.description)
    }

  }

  func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return 1
  }


  func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return productsArray.count
  }


  func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return 80.0
  }

  func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("idCellProduct", forIndexPath: indexPath) 

    let product = productsArray[indexPath.row]
    cell.textLabel?.text = product.localizedTitle
    cell.detailTextLabel?.text = product.localizedDescription

    return cell
  }



  override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */


    // MARK: IBAction method implementation

    @IBAction func dismiss(sender: AnyObject) {
        dismissViewControllerAnimated(true, completion: nil)
    }

    // MARK: UITableView method implementation

}

When I come to purchase page I expect to see list of products but I got only "There are no products. ["iapdemo_extra_colors_colect_1", "iapdemo_extra_colors_colect_2"]" in the console.

I tried some more tutorials and apple sample code to check my in-app purchase but with no luck.

After I downloaded Apple sample code to check in-app purchase from https://developer.apple.com/library/ios/samplecode/sc1991/StoreKitSuite.zip

And I got my single product id in invalidProductIdentifiers array. So I found the list of troubleshooting (from Apple):

  1. You did not use an explicit App ID.
  2. If you or App Review rejected your most recent binary in iTunes Connect.
  3. You did not clear your In-App Purchase products for sale in iTunes Connect.
  4. You did not sign your app with the Provisioning Profile associated with your explicit App ID.
  5. You might have modified your products, but these changes are not yet available to all the App Store servers.
  6. You did not complete all the financial requirements. See Contracts, Tax, and Banking Information for more information.
  7. Your product is an Apple-hosted one whose content has not yet been uploaded to iTunes Connect.

I got answers

  1. I use explicit app id
  2. my app was not rejected as it is test and I didn't try to submit it
  3. I have single product for sale
  4. provisioning profile set to automatic. And I also tried to make one and use it in xcode
  5. I did't modified anything for an hour (may be I need to wait a little longer?)
  6. Tax and Bank accounts filled
  7. Not Apple-hosted

Any ideas guys?

1
Are the 2 products which you added in itunesconnect approved?haluzak
Yes. I added exactly two products and copied their IDs to the code to be sure that I've made that correct.wm.p1us
It usually takes some time even after approval before they start appearing in your app. Anyway you have to test on real device and make sure your app id, provisioning profiles and bundle id are matching and are setup correctly.haluzak
Should I connect test user before I run test app?wm.p1us
Yes, you can switch to test user in app store and then try running your app.haluzak

1 Answers

0
votes

The problem was in provisioning profile. It was for some reason incorrect so I've made it by myself and it is start working well.

As well I found that this problem can be met if you have some issues with your certificates but was not my case!

Hope it helps someone!