我正在尝试在游戏中实现应用内购买,但是当我将可用产品集发送到我的产品请求功能时,该产品集将被清除。
这是为了购买少量广告来禁用广告。启动请求的按钮起作用,并且fetchAvailableProducts中的productIdentifiers包含正确的产品,但是在productRequest中该集合为空。
func fetchAvailableProducts(){
// Put here your IAP Products ID's
let productIdentifiers = NSSet(objects: NON_CONSUMABLE_PURCHASE_PRODUCT_ID)
print(productIdentifiers as! Set<String>)
productsRequest = SKProductsRequest(productIdentifiers: productIdentifiers as! Set<String>)
productsRequest.delegate = self
productsRequest.start()
}
extension IAPHandler: SKProductsRequestDelegate, SKPaymentTransactionObserver{
// MARK: - REQUEST IAP PRODUCTS
func productsRequest (_ request:SKProductsRequest, didReceive response:SKProductsResponse) {
if (response.products.count > 0) {
iapProducts = response.products
for product in iapProducts{
let numberFormatter = NumberFormatter()
numberFormatter.formatterBehavior = .behavior10_4
numberFormatter.numberStyle = .currency
numberFormatter.locale = product.priceLocale
let price1Str = numberFormatter.string(from: product.price)
print(product.localizedDescription + "\nfor just \(price1Str!)")
}
} else {
print("products list is empty")
}
}
控制台输出为:
[“ com.me.myapp.noAds”]
产品列表为空
我已经检查了协议,在我的应用中打开了应用内购买,并将应用内购买添加到应用商店连接:
答案 0 :(得分:1)
请检查下面是否已全部完成。