ios – SKPaymentQueue.canMakePayments()始终返回true

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

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

当您禁用应用程序内购买时,限制SKPaymentQueue.canMakePayments()应该返回false,但无论如何它总是返回true.我尝试了两个不同的项目,包括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)
    }
}

最佳答案 我有同样的问题.也许这会对你有所帮助.

https://forums.developer.apple.com/thread/22312

我也认为这似乎是一个错误.

我用iOS 7.1.2和8.4.1测试了这个.即使“应用程序内购买”已关闭且“安装应用程序”已启用,SKPaymentQueue.canMakePayments()也会返回false.

点赞