gpt4 book ai didi

ios - SKPaymentQueue.canMakePayments() 总是返回 true

转载 作者:搜寻专家 更新时间:2023-10-31 21:48:18 26 4
gpt4 key购买 nike

重要的是检查是否启用了应用内购买以正确阻止 UI,RayWenderlich 博客说:

Apple requires that you handle this situation gracefully; not doing so will likely result in an app rejection.

当您禁用应用内购买时,限制 SKPaymentQueue.canMakePayments() 应该返回 false 但无论如何它总是返回 true .我尝试了 2 个不同的项目,包括 this one from RayWenderlich.

我只在 iOS 9 上测试过。

如何识别因家长限制而禁用的应用内购买?

更新。
有人要求分享我的代码。我觉得没必要,代码很明显,没有错误。我也可以用 Ray 的项目重现这个问题。

// This function is called in from viewDidLoad()
// And after SKProduct is updated.
func addTextFromProduct(p: SKProduct) {

if let title = p.localizedTitle as String? {
self.navigationBar.topItem?.title = title
}

if let description = p.localizedDescription as String? {
if dailyLimit {
self.informationLabel.text? = "\(waitingTime)\(description)"
} else {
self.informationLabel.text? = "\(description)"
}

if SKPaymentQueue.canMakePayments() {
unblockButtons()
}

} else {
self.informationLabel.text? = "\(waitingTime)\(description)\n\nIn-App Purchase is unavailable at this moment."
blockButtons()
}

if SKPaymentQueue.canMakePayments() {
self.priceFormatter.locale = p.priceLocale
let localPrice: String! = self.priceFormatter.stringFromNumber(p.price)
let label = "\(localPrice)"
self.buyButton.setTitle(label, forState: UIControlState.Normal)
} else {
blockButtons()
buyButton.setTitle("Not Available", forState: UIControlState.Disabled)
}
}

最佳答案

如果用户启用了 IAP,您需要检查 viewDidLoad 方法。

if(SKPaymentQueue.canMakePayments()) {

print("IAP is enabled, loading")

// Your Products


let request: SKProductsRequest = SKProductsRequest(productIdentifiers: productID as! Set<String>)
request.delegate = self
request.start()



}
else {

print("IAP not allowed")
//Do something like show an alert, the user has not allowed in app purchases

}

关于ios - SKPaymentQueue.canMakePayments() 总是返回 true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32638570/

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