【问题标题】:In app purchase testing (can't see my products)应用内购买测试(看不到我的产品)
【发布时间】:2015-10-07 09:05:21
【问题描述】:

所以我按照教程并尝试使用 IAP 制作一个测试应用。

1) 我创建了新的 App ID

2) 添加了 ID 为 iapdemo_extra_colors_colect_1 和 iapdemo_extra_colors_colect_2"

的两种消耗品

3) 在 iTunes 连接中创建测试用户

4) 创建和应用。

5) 使用 tableView 视图制作单独的购买页面

6) 将 App ID bundle id 复制到 info.plist 到“Bundle identifier”

7) 我的购买页面代码是:

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

}

当我来到购买页面时,我希望看到产品列表,但我只看到“没有产品。 ["iapdemo_extra_colors_colect_1", "iapdemo_extra_colors_colect_2"]" 在控制台中。

我尝试了更多教程和苹果示例代码来检查我的应用内购买,但没有成功。

在我下载 Apple 示例代码以检查应用内购买后 https://developer.apple.com/library/ios/samplecode/sc1991/StoreKitSuite.zip

我在 invalidProductIdentifiers 数组中获得了我的单个产品 ID。所以我找到了故障排除列表(来自Apple):

  1. 您没有使用明确的 App ID。
  2. 如果您或 App Review 拒绝了您在 iTunes Connect 中的最新二进制文件。
  3. 您没有在 iTunes Connect 中清除要出售的应用内购买产品。
  4. 您没有使用与您的显式应用 ID 关联的配置文件对您的应用进行签名。
  5. 您可能已经修改了您的产品,但这些更改尚不适用于所有 App Store 服务器。
  6. 您没有完成所有财务要求。有关详细信息,请参阅合同、税务和银行信息。
  7. 您的产品是 Apple 托管的产品,其内容尚未上传到 iTunes Connect。

我得到了答案

  1. 我使用显式应用 ID
  2. 我的应用没有被拒绝,因为它是测试,我没有尝试提交它
  3. 我有单品出售
  4. 配置文件设置为自动。我也尝试制作一个并在 xcode 中使用它
  5. 我一个小时没有修改任何东西(可能我需要再等一会儿?)
  6. 税务和银行账户填写
  7. 非 Apple 托管

各位有什么想法吗?

【问题讨论】:

  • 您在itunesconnect中添加的2个产品是否获得批准?
  • 是的。我准确地添加了两个产品并将它们的 ID 复制到代码中以确保我所做的正确。
  • 即使在获得批准后,它们通常也需要一段时间才能开始出现在您的应用中。无论如何,您必须在真实设备上进行测试,并确保您的应用 ID、配置文件和捆绑包 ID 匹配且设置正确。
  • 我应该在运行测试应用之前连接测试用户吗?
  • 是的,您可以在应用商店切换到测试用户,然后尝试运行您的应用。

标签: ios swift in-app-purchase swift2


【解决方案1】:

问题出在配置文件中。由于某种原因不正确,所以我自己做了它,它开始运行良好。

我还发现,如果您的证书有问题但不是我的情况,可以解决这个问题!

希望对某人有所帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-16
    • 2017-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多