检查是应用内购买才能正常阻塞UI,RayWenderlich博客说,这是很重要的:SKPaymentQueue.canMakePayments()总是返回true
苹果要求你优雅地处理这种情况;不这样做可能会导致应用程序拒绝。
当禁用应用程序内购买,这些限制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)
}
}
我在iOS的早期版本中遇到了同样的问题,但是如果InAppPurchases受限,canMakePayments会正确返回false,但是在iOS 9上它似乎反映了安装应用程序限制? – Michael
已确认,Xcode 7.2.1,iOS 9.2.1,已启用ARC的canMakePayments只会在加载应用程序后限制安装应用程序时返回false。以下是有关如何设置和使用限制的有用链接:https://support.apple.com/en-us/HT204396。有关此问题的任何更新? –