iphone - 检查 InApp 购买是否受到限制

标签 iphone ios in-app-purchase

在 iPhone 上,我可以进入“常规”->“限制”并锁定 InApp 购买。在代码方面,我如何检查用户是否已执行此操作?

最佳答案

有一个名为 SKPaymentQueue 的 StoreKit 类它有一个类方法 canMakePayments,它可以告诉您用户是否可以进行您可以检查的购买

if ([SKPaymentQueue canMakePayments]) {
    // user can make purchases
} else {
    // no purchases can be made, show error
}

文档说:

An iPhone can be restricted from accessing the Apple App Store. For example, parents can restrict their children’s ability to purchase additional content. Your application should confirm that the user is allowed to authorize payments before adding a payment to the queue. Your application may also want to alter its behavior or appearance when the user is not allowed to authorize payments.

关于iphone - 检查 InApp 购买是否受到限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7730024/

相关文章:

iphone - 我们可以对多个 ios (ipad/iphone) 应用程序使用相同的图标吗?

iphone - NSMutableArray比较不同计数

iOS 应用程序 - 将代码和内容与各种元素分离

ios - H27-客户请求中断

安卓 : In App Purchase

iphone - 从另一个 View 中选择 TableView 的行

iphone - iPhone中的内存分配

objective-c - MPMediaQuery artistsQuery 返回重复项

xcode - 沙盒环境中的 macOS 应用内购买未授权

ios - Apple 应用内购买 transaction_id 是全局唯一的吗?