首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iOS应用程序的回执验证代码不起作用

iOS应用程序的回执验证代码不起作用
EN

Stack Overflow用户
提问于 2019-04-14 13:35:59
回答 1查看 111关注 0票数 0

Raywenderlich tutorial之后,我第一次在iOS应用程序中实现了Receipt-Validation代码

尽管它在测试期间运行良好,但使用的是沙盒。在现实中,它并不像预期的那样工作。

下载应用程序后,所有功能都可以从start开始使用;这意味着无需检查iap内容的购买情况。

在Sandbox的例子中,我需要购买才能获得收据,而“购买”意味着“获取iap的内容”。

据我所知,在现实世界中,收据是随应用程序一起提供的。我的解释是,我可能没有检查我应该在代码中做什么。

该领域专家的任何指导都将非常感谢。

看一下代码,似乎(确实)没有太多的检查,除了确保他们的是一个有效的(格式良好的)收据。但我想我需要更多的东西来检查IAP的内容是否已经支付。

下面是我认为的相关代码:

代码语言:javascript
复制
func validateReceipt() {

    receipt = Receipt()

    if let receiptStatus = receipt?.receiptStatus {
        guard receiptStatus == .validationSuccess else {
            return
        }

        // If verification succeed, we show information contained in the receipt.
        // print("Bundle Identifier: \(receipt!.bundleIdString!)")
        // print("Bundle Version: \(receipt!.bundleVersionString!)")

        if let originalVersion = receipt?.originalAppVersion {
            //print("originalVersion: \(originalVersion)")
        } else {
            //print("originalVersion: Not Provided")
        }

        if let receiptExpirationDate = receipt?.expirationDate {
            //print("Expiration Date: \(formatDateForUI(receiptExpirationDate))")
        } else {
            //print("Expiration Date: Not Provided")
        }

        if let receiptCreation = receipt?.receiptCreationDate {
            //print("receiptCreation: \(formatDateForUI(receiptCreation))")
        } else {
            //print("receiptCreation: Not Provided")
        }

        // At this point we should enable full features if it is not yet the case.
        .... code to unlock full features .....
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-14 14:27:16

您应该检查类型为17xx的字段,您可以在其中找到产品标识符(字段类型1702)和购买日期(字段类型1704)。你在部分阅读应用内购买中提到的Raywenderlich教程中描述了这一点。

因此,您可以查看用户是否购买了带有您感兴趣的产品标识的IAP。产品标识符与您在App Store Connect at MyApps -> Feature -> IAP上选择的相同。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55672264

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档