StoreKit - 如何获得正确的有效期?

时间:2011-11-15 14:43:43

标签: ios date subscription storekit

我已经让StoreKit为自动续订订阅工作,并且可以通过Sandbox成功购买和续订订阅。到目前为止,非常好。

我遇到的问题是苹果返回的失效日期似乎不正确。

首次购买订阅时,它会为您提供receipt响应。在此回复中,它会为您expires_date_formatted提供,这是通过查询苹果回复的receiptlatest_receipt_info部分获得的。

订阅过期后,您会收到latest_expired_receipt_info回复(这不会出现在常规购买中,只有在收据过期时才会显示)。

无论出于何种原因,latest_expired_receipt_infoexpires_date_formatted内都有一个不同的日期,这会让我感到各种麻烦。

通常我的应用会报告订阅已过期,但当您尝试重新购买订阅时,会说订阅仍处于有效状态。

这似乎意味着latest_expired_receipt_info内的日期是准确的,但似乎无法获得该日期(除非您故意让订阅过期)。

示例:

receipt (stored) = {
    bid = "myappid.goeshere";
    bvrs = "1.0";
    "expires_date" = 1321365095905;
    "expires_date_formatted" = "2011-11-15 13:51:35 Etc/GMT";
    ...other stuff....
}
latest_expired_receipt_info = {
    bid = "myappid.goeshere";
    bvrs = "1.0";
    "expires_date" = 1321366860000;
    "expires_date_formatted" = "2011-11-15 14:21:00 Etc/GMT";
    ...other stuff...
}

在上面的例子中,我们可以看到expires_date_formatted完全不同,一个说13:51,另一个说14:21

在其他测试中,差异可以是几分钟到十分钟或二十分钟。

如何获得正确的expires_date_formatted

0 个答案:

没有答案
相关问题