【问题标题】:Does refreshReceipt ask for AppStore credentials?刷新收据是否要求 App Store 凭据?
【发布时间】:2019-06-12 08:42:56
【问题描述】:

我一直在一个示例应用中测试 iOS 应用内购买。我需要弄清楚我是否可以在发布时立即调用refreshReceipt API 来检查用户是否有资格获得某些试用期订阅等。

我在 AppDelegate 的 application:didFinishLaunching:options 方法中调用了 refreshReceipt,但它要求我提供 AppStore 凭据,基本上是沙盒用户的密码。我没想到会从 Apple 文档中看到这种行为。是因为沙盒环境而发生的事情,还是在生产环境中也发生了。

另外,Restore Purchase 是否会触发 AppStore 登录警报。 Apple 文档说确实如此,但最近我看到我手机上的一个音乐应用程序在我选择该选项时没有要求提供凭据。可能他们没有调用 StoreKit 的 restorePurchase API,而是使用他们自己的机制。

【问题讨论】:

    标签: ios in-app-purchase storekit receipt-validation


    【解决方案1】:

    只要设备上没有收据,您就会收到登录提示。在沙盒中,没有安装收据,因此您总是会看到弹出窗口。您还应该注意到,收据在沙盒中刷新后仍然不存在,除非您进行了购买。

    如果用户登录到他们的 iTunes 帐户,收据应该在生产中始终存在。

    对于恢复,我会假设它遵循相同的逻辑(如果收据不存在则要求提示)但这与 Apple 所说的相矛盾。

    【讨论】:

    • 这是有道理的,因为如果收据已经存在,收据本身就构成了续订的身份验证基础。在没有它的情况下,可能需要进行身份验证。是的,这也在沙盒中验证。
    • 我在 Apple 文档中找到了这个:The absence of the appStoreReceipt is typical when the application is installed using Xcode or TestFlight. When the application is installed from the App Store or restored from iCloud, the appStoreReceipt will always be present. - apple.co/31yL7cP
    • You should also notice that the receipt still doesn't exist after it's refreshed in sandbox unless you made a purchase. - 在通过 XCode 进行初始安装时,收据不存在,但是当 refreshReceipt 被调用一次时,即使没有购买也可以获得收据。自己测试过。
    猜你喜欢
    • 2022-12-14
    • 2011-05-14
    • 1970-01-01
    • 2018-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-28
    相关资源
    最近更新 更多