MKStoreKit autorenewable subscriptions

懵懂的女人 提交于 2019-12-05 14:08:38
Joseph Chen

The documentation says:

For the sake of testing, there are some differences in behavior between auto-renewable subscriptions in the production environment and in the test environment.

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 subscription renewal and how it handles a renewal after a lapse and how it handles 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.

Could you try to:

  1. test a longer subscription period, so that the "system" has more time to renew the subscription (6mo = 30min, 1y = 1h)?
  2. run a timer to keep checking if the subscription renews after an extended period of time?
  3. force renewal by restoring the purchase?

Also, as detailed here make sure you have not waited more than six times the subscription period before checking, as the subscription can renew for a single test account only six times a day.

I'm just about to start implementing this in my own app, so I'll write back if I encounter the same situation.

UPDATE:

I read (somewhere) that autorenewal occurs when an app is launched in the period after 24 hours before expiration. This may be hard to replicate in the sandbox. Renewal can also be forced by refreshing the app receipt (>= iOS 7) or re-verifying the receipt from the most recent purchase (< iOS 7).

I've posted my implementation on github for your perusal.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!