自动续订订阅 IAP 在沙盒中到期后续订

Autorenewable subscription IAP renewing after expiry date in sandbox

根据 Apple 的文档...

During the 24-hour period before the subscription expires, the App Store starts trying to automatically renew it. The App Store makes several attempts to automatically renew the subscription over a period of time but eventually stops if there are too many failed attempts.

我 运行 一个脚本,它通过将收据发送给苹果然后检查响应以查看它是否已续订来确定订阅是否已过期。如果它没有并且当前订阅到期日期在我 运行 宁脚本的时间之前,我将其视为过期订阅,因为我假设它会在前 24 小时(或等效时间)内更新不久之前在沙箱环境中)。

在沙盒上,我看到订阅可以在到期日期后续订的行为 - 我将其标记为已过期,然后在将来 运行 响应中有续订。

例如订阅的到期日期为“2017-02-08T15:32:41Z”,因此我希望苹果在此之前显示续订。但是它没有,所以我标记为已过期。在脚本的下一个 运行 中,出现了到期日期为“2017-02-08T15:39:55Z”的续订,比上一个到期日期晚了 7 分钟以上,这表明续订发生在 2 分钟后之前的到期日期(考虑沙盒中 5 分钟的订阅时长)。有很多这样的例子。

我的问题是我应该如何解释生产中的这种行为?它发生了吗?看到到期日期已经过去,我是否应该表现得好像订阅已过期?或者我应该留出更多时间,因为沙盒行为与文档相矛盾。

回答我自己的问题。从文档...

Renewal happens at an accelerated rate, and auto-renewable subscriptions renew a maximum of six times per day. This lets you test how your app handles a subscription renewal, a subscription lapse, and a subscription history that includes gaps.

Because of the accelerated expiration and renewal rate, the subscription can expire before the system starts trying to renew the subscription, leaving a small lapse in the subscription period. Such lapses are also possible in production for a variety of reasons—make sure your app handles them correctly.