How to test the “renew” component of auto-renew subscriptions in iOS App Store Sandbox?

前提是你 提交于 2019-12-02 17:10:36
Ghazanfar Ali

Copied from the Apple's Developer Forum, for those not willing to goto the forum...

Figured it out (but not thanks to the Apple docs):

1 month subscriptions auto-renew every 5 minutes. So far so good. They auto-renew 5 times and then they stop, so after 25 minutes you'll get the 21006 error. However even when repurchasing the same subscription it will NOT auto-renew again on the same test account since it has already auto-renewed 5 times. So if you want to test renewal and you have been messing with these subscriptions for a while you need to create a new itunes connect test user. This is very annoying honestly and it would be a lot easier if we could just reset the entire purchase history of a test user account. Also putting all in-app test information in the Xcode documentation would be a lot better as opposed to spreading it over Xcode docs/iTunes Connect doc/people figuring stuff out themselves

Hope this helps.

This conversation in the Apple dev forums may shed some light on this issue for others who discover this post: https://devforums.apple.com/thread/105350?tstart=0

@Lata Sadhwani, App developer

For testing auto-renew subscriptions, the expiration time is 5 minutes in sandbox (at least for the monthly subscriptions, not sure if this is different for different periods). So when testing an auto-renew subscription in sandbox, it should auto-renew every 5 mins and you know they are working correctly.

But there is one problem. These subscriptions auto-renew only 5 times (i.e. the purchase happens 6 times). After that you'll get an error when verifying the receipt. So if you want to test after that, you will need to test with another IAP test account (yes it is a pain testing, especially if you have been doing this for quite some time!)

To check if a subscription has been cancelled or is valid, your receipt verification code will need to parse the response from Apple servers and they say you should verify each receipt. If the subscription has expired or has been cancelled, the appropriate error code will be returned (a non-zero status). If it has been renewed by a user, the most current receipt is returned by the Apple servers.

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