【问题标题】:iOS subscription DID_CHANGE_RENEWAL_STATUS notification: latest_expired_receipt vs latest_receiptiOS 订阅 DID_CHANGE_RENEWAL_STATUS 通知:latest_expired_receipt vs latest_receipt
【发布时间】:2019-10-22 16:43:42
【问题描述】:

我正在为我的 iOS 应用添加订阅,但遇到了一些非常烦人的不一致:

我的服务器正在监听来自 Apple 的 DID_CHANGE_RENEWAL_STATUS 通知:

{
    "auto_renew_status_change_date": "2019-06-05 13:42:43 Etc/GMT",
    "environment": "Sandbox",
    "auto_renew_status": "false",
    "auto_renew_status_change_date_pst": "2019-06-05 06:42:43 America/Los_Angeles",
    "latest_expired_receipt": "ewoJIn...",
    "latest_expired_receipt_info": ⊖{
        "original_transaction_id": "10000001010101010",
        "expires_date_formatted": "2019-06-05 13:43:13 Etc/GMT",
        ...
    },
    "password": "xxxxxxxxx",
    "auto_renew_status_change_date_ms": "1559742163000",
    "auto_renew_product_id": "com.my.product",
    "notification_type": "DID_CHANGE_RENEWAL_STATUS"
}

在我的测试中,几乎所有情况下的通知都包含latest_expired_receiptlatest_expired_receipt_info

但是某些消息包含latest_receiptlatest_receipt_info。除了这种差异之外,消息的结构是相同的("auto_renew_status": "false"auto_renew_status_change_date 之前 expires_date_formatted 等)

Apple 是否会随机更改结构以使实施订阅更加愉快,或者是否有任何关于何时使用哪种结构的逻辑?

当然,我可以简单地调整我的服务器代码以检查 latest_receipt 是否可用 OR latest_expired_receipt 可用,但这将是一个快速而肮脏的解决方案。我更愿意了解什么时候可以期待哪些内容/结构......

【问题讨论】:

  • 您好,您找到解决方案了吗?如果是,请分享
  • 并非如此。我的解决方案是检查这两个字段并使用可用的字段。我没有找到关于何时使用哪个字段的信息,但似乎它们没有同时使用......

标签: ios in-app-purchase subscription in-app-subscription


【解决方案1】:

如果在自动更新状态发生变化时订单已过期,您将获得 latest_expired_receipt_info 和 latest_expired_receipt(这种情况包括正在计费重试且应用商店在计费重试期间无法续订的订单,或者订单已退款),对于订阅仍然有效的其他情况,您将获得 latest_receipt 和 latest_receipt_info

【讨论】:

    【解决方案2】:

    latest_expired_receipt_info - 此数组出现在通知中,而不是 过期 交易的 latest_receipt_info。你可以查看苹果官方文档here。 另请注意 Apple 的文档:以下顶级对象计划弃用:latest_receipt、latest_receipt_info、latest_expired_receipt 和 latest_expired_receipt_info。

    您还可以考虑使用像 Qonversion.io 这样的第三方服务,以避免在实施订阅时遇到麻烦,并获得开箱即用的订阅分析集成。

    【讨论】:

      【解决方案3】:

      Apple 不断让开发者的生活变得更加艰难。

      如 App Store 服务器通知文档中所述,顶级对象 latest_receipt、latest_receipt_info、latest_expired_receipt 和 latest_expired_receipt_info 计划弃用。这可能是通知行为不同的原因。

      您应该更新您的代码以依赖 unified_receipt中的 latest_receiptlatest_receipt_info > 对象。 来源:https://developer.apple.com/documentation/appstoreservernotifications/responsebody

      【讨论】:

      • 感谢这个重要的提示!使用 Apple API 和服务总是很有趣......但是,到目前为止,我无法在任何收到的交易中找到 unified_receipt 字段?!看来必须好好猜测一下收据应该是什么样子了,哪个字段可能有什么含义……
      猜你喜欢
      • 2012-01-28
      • 2019-11-07
      • 2021-04-25
      • 2012-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-13
      • 2015-01-20
      相关资源
      最近更新 更多