【问题标题】:How to get the correct original purchase and expires date in IAP Swift如何在 IAP Swift 中获得正确的原始购买和过期日期
【发布时间】:2019-02-06 16:25:14
【问题描述】:

我目前正在沙盒中测试应用内购买,以查看用户订阅当前是否有效或已过期。我刚订阅了一个月,收据上说订阅马上就过期了。 orginalPurchaseDate 和 ExpiryDate 看起来都是错误的。我如何确定 json 中的哪些日期是正确的。我将 expiryDate 与原始购买日期进行比较,以确定订阅是否仍然有效。

func checkIfSubscriptionIsActive() {
    IAPManager.shared.validatePurchaseReceipt { (pReceipt) in
        self.receipt = pReceipt
        let expiryDate = self.receipt.last.map { $0.expiresDate}!.skTodate
        let originalPurchaseDate = self.receipt.last.map { $0.originalPurhaseDate}!.skTodate
        print("Latest Receipt: \(self.receipt.last)")
        if expiryDate?.compare(originalPurchaseDate!) == .orderedDescending {
            print("Subscription is expired")
        } else {
            print("Subscription is still active")
        }
    }
}

这是我的日志

最新收据:可选(Vinylly.IAPReceiptInfo(数量:“1”,tansactionID:“1000000500500768”,productID:“com.myApp.skLLC.autoRenewableSubscription”,originalPurhaseDate:“2019-01-17 11:50:53 等/GMT", isTrialPeriod: "false", webOrderLineItem: "1000000042609588", expiresDate: "2019-02-06 15:55:21 Etc/GMT"))

【问题讨论】:

  • 不是原购买日期总是在过期日期之前吗?

标签: ios swift in-app-purchase


【解决方案1】:

根据苹果文档,当您在沙盒环境中测试时,一个月的订阅将在 5 分钟后到期。如果您想围绕此编写/测试一些代码,请尝试在 5 分钟内完成。

【讨论】:

  • 非常感谢。我以为我做错了,这更有意义
猜你喜欢
  • 1970-01-01
  • 2016-09-27
  • 2022-06-14
  • 1970-01-01
  • 2011-12-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-03
相关资源
最近更新 更多