iPhone:以编程方式检查应用内购买状态

发布于 2024-12-26 07:10:27 字数 92 浏览 0 评论 0原文

如您所知,可以从“设置”->“常规”->“限制”打开和关闭应用内购买。现在我想知道,在我们实际进行任何付款之前,有什么方法可以以编程方式检查应用内购买的状态。

As you know that, In-App Purchase can be turned on and off from Settings->General->Restrictions. Now i am wondering, is there any way to check the status of of In-App Purchase programmatically, before we actually make any payment.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

习ぎ惯性依靠 2025-01-02 07:10:27

我在 SKPaymentQueue 类中找到了解决方案。我正在使用“canMakePayments”方法来检查应用内购买的限制。

来自 Apple 文档:

SKPaymentQueue 类参考:canMakePayments< /a>

“可以限制 iPhone 访问 Apple App Store。例如,家长可以限制孩子购买额外内容的能力。您的应用程序应在将付款添加到队列之前确认允许用户授权付款。当不允许用户授权付款时,您的应用程序可能还想改变其行为或外观。”

示例代码:

if ([SKPaymentQueue canMakePayments])
{
    SKPayment *payment = [SKPayment paymentWithProductIdentifier:identifier];
    [[SKPaymentQueue defaultQueue] addPayment:payment];
} else {
    NSLog(@"In-App Purchases are not allowed");     
}

I've got the solution in SKPaymentQueue class. I am using the "canMakePayments" method to check the restrictions on In-App Purchases.

From Apple Documentation:

SKPaymentQueue Class Reference: canMakePayments

"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."

Sample Code:

if ([SKPaymentQueue canMakePayments])
{
    SKPayment *payment = [SKPayment paymentWithProductIdentifier:identifier];
    [[SKPaymentQueue defaultQueue] addPayment:payment];
} else {
    NSLog(@"In-App Purchases are not allowed");     
}
花伊自在美 2025-01-02 07:10:27

大多数用户设置可以通过读取存储在 /User/Library/Preferences/ 中的属性列表来访问。 但由于沙箱限制,您可能无法访问其中某些设置。所以你必须通过代码来尝试一下。

Most of the user settings can be accessed by reading the property lists stored at /User/Library/Preferences/. But there are chances you might not be able to access some of these due to sandbox restriction. So you will have to try this out via code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文