gpt4 book ai didi

ios - 应用内购买错误,始终 myProduct 为 0

转载 作者:行者123 更新时间:2023-11-28 08:09:06 32 4
gpt4 key购买 nike

我的 VC 是这样的:

var coins = 50 // coins
override func viewDidLoad() {
super.viewDidLoad()
if(SKPaymentQueue.canMakePayments()) {
//print("enabled, loading")
let productID: NSSet = NSSet(objects: "com.tahabuyruk.taha.coinsal", "com.tahabuyruk.taha.reklam") // my products Id
let request: SKProductsRequest = SKProductsRequest(productIdentifiers: productID as! Set<String>)
request.delegate = self
request.start()
} else {
print("please enable IAPS")
}
}

//I have 2 products on itunesconnect

@IBAction func btnRemoveAds(_ sender: Any) {
print("rem ads")
for product in list {
let prodID = product.productIdentifier
if(prodID == "com.tahabuyruk.taha.reklam") {
// ad product id
p = product
buyProduct()
}
}
}

// my bundle id is com.tahabuyruk.taha
// my product id is com.tahabuyruk.taha.coins

@IBAction func satinAl(_ sender: Any) { // addCoin Button
for product in list {
let prodID = product.productIdentifier
if(prodID == "com.tahabuyruk.taha.coinsal") {
p = product
buyProduct()
}
}
}

func buyProduct() {
print("buy " + p.productIdentifier)
let pay = SKPayment(product: p)
SKPaymentQueue.default().add(self)
SKPaymentQueue.default().add(pay as SKPayment)
}

func removeAds() {
lblAd.removeFromSuperview()
}

func addCoins() {
coins += 50
lblCoinAmount.text = "\(coins)"
}

var list = [SKProduct]()
var p = SKProduct()

func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
print("product request")
let myProduct = response.products // myProduct is always be 0 . I don't know why .
for product in myProduct {
print("product added")
print(product.productIdentifier)
print(product.localizedTitle)
print(product.localizedDescription)
print(product.price)
list.append(product)
}
}

func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue) {
print("transactions restored")
for transaction in queue.transactions {
let t: SKPaymentTransaction = transaction
let prodID = t.payment.productIdentifier as String

switch prodID {
case "com.tahabuyruk.taha.reklam":// ad product id
print("remove ads")
removeAds()
case "com.tahabuyruk.taha.coinsal":
print("add coins to account")
addCoins()
default:
print("IAP not found")
}
}
}

func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
print("add payment")

for transaction: AnyObject in transactions {
let trans = transaction as! SKPaymentTransaction
print(trans.error)

switch trans.transactionState {
case .purchased:
print("buy ok")
print(p.productIdentifier)

let prodID = p.productIdentifier
switch prodID {
case "com.tahabuyruk.taha.reklam":// ad product id
print("remove ads")
removeAds()
case "com.tahabuyruk.taha.coinsal":
print("add coins to account")
addCoins()
default:
print("IAP not found")
}
queue.finishTransaction(trans)
case .failed:
print("buy error")
queue.finishTransaction(trans)
break
default:
print("Default")
break
}
}
}

myProduct 始终为 0。这段代码有什么问题?我想知道为什么总是0?

最佳答案

我处理这个问题,查找协议(protocol)、税务和银行业务,并检查您的银行业务、联系方式和税务信息是否已填写

关于ios - 应用内购买错误,始终 myProduct 为 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44205857/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com