我试图从App Store Connect获取应用内购买,如下所示:
private let kOneMonthSubscriptionId = "DOUBLESPEEDENERGY"
func loadProducts() {
let identifiers = Set([kOneMonthSubscriptionId])
let request = SKProductsRequest(productIdentifiers: identifiers)
request.delegate = self
request.start()
}
override func viewDidAppear(_ animated: Bool) {
if SKPaymentQueue.canMakePayments()
{
loadProducts()
}
}
extension homeVC: SKProductsRequestDelegate {
func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
if response.products.count > 0 {
print("Purchasable products available!")
// 1. Save the SKProduct's so you could let the user make a purchase
// 2. Update the UI - it lets you change the product prices without updating the app
} else {
print("No purchasable products available.")
// This might happen when your product identifiers are incorrect or your in-app purchases products weren't processed on iTunes Connect yet
}
}
请查看我的代码是否有问题,我真的很感激!
在此先感谢您的帮助!
最可能的原因是您在App Store Connect(协议,税务和银行部分(付费应用))中没有应用内购买设置的银行方法,如果您没有,那么您的应用无法访问In-应用购买服务,因为即使您处于沙盒环境中,它也不知道在哪里进行付款。
如果这无助于查看其他可能性,那么为什么它不起作用:
希望这可以帮助!