我在iTunes connect中创建了一个可消费的应用内购买,如下图所示。
之后,我创建了一个沙盒用户,并验证了appid。
当我试图使用以下代码检查产品时
func requestProducts(forIds ids: Set<String>)
{
productRequest.cancel()
productRequest = SKProductsRequest(productIdentifiers: "com.iapcourse.meal")
productRequest.delegate = self
productRequest.start()
}
func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
self.products = response.products
print(products.count)
if products.count == 0
{
requestProducts(forIds: "com.iapcourse.meal")
}
else {
delegate?.iapProductsLoaded()
}
}
我从delegate方法得到零积。
最佳答案
在沙盒中测试之前,应用内购买的状态需要处于“准备提交”阶段。一个常见的错过是预览图像,为了测试,你可以上传任何你想要的,所以元数据是完整的。另外,你需要确保你已经签署了“付费应用”协议-在App Store connect的任何地方都不清楚这是必需的,所以有时会被忽略。
我真的很好的文章,你需要配置的所有东西的清单是:Configuring In-app Products is Hard