iOS自动续订订阅 - 有关续订过程的问题 [英] iOS auto-renewable subscriptions - Questions regarding the renewing process

查看:326
本文介绍了iOS自动续订订阅 - 有关续订过程的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个问题可以帮助我更好地理解问题,如果回答:

I have a few questions that will help me understand things better if answered:


  1. 有没有办法区分新订阅和续订先前购买的订单?

  1. Is there a way to differentiate between a fresh subscription and the renewal of a previously-purchased one?

订阅expires_date后,订阅是否会立即完成续订过程?似乎有时(至少在Sandbox中)我的订阅将在expires_date之前续订30-60秒。

Does the subscription go through the renewal process immediately after the expires_date is hit? It seems that sometimes (in the Sandbox, at least) my subscriptions will renew 30-60 seconds before the expires_date.

续订是否总是以一致的方式发生expires_date被击中后的时间?例如,如果我启动了我的app并且expires_date已经通过,那么更新何时发生(假设用户没有取消)?或者更确切地说,我的应用程序什么时候才能知道Apple的更新已经发生?

Does the renewal always happen at a consistent time after the expires_date is hit? For instance, if I launch my app and expires_date has been passed, when will the renewal occur (assuming the user didn't cancel)? Or rather, when will my app know that the renewal has occurred on Apple's end?

场景:应用程序已启动且expires_date已通过其中一个订阅。我是否应该向Apple发送收据以查看该订阅是否已续订,或者我应该等待几秒钟以确定续订过程是否发生?

Scenario: app is launched and expires_date has passed for one of my subscriptions. Should I send a receipt to Apple to see if that subscription was renewed, or should I wait a couple seconds to see if the renewal process occurs?

谢谢!

推荐答案

我将尝试回答我自己的问题:

I will attempt to answer my own question:


  1. 为此,我在 NSUserDefaults <中存储订阅的 expires_date / code>初次购买完成后。订阅到期后,我从 NSUserDefaults 中删除​​该对象。这允许我确定NSUserDefaults中是否存在任何后续订阅续订 expires_date - 更新为新 expires_date 续订完成时)或新购买 expires_date 不存在,因为它在之前的订阅到期时被删除或该产品从未被购买过。)

  1. To do this, I store expires_date of the subscription in NSUserDefaults once the initial purchase is completed. When the subscription expires, I remove the object from NSUserDefaults. This allows me to determine if any subsequent subscriptions are a renewal (expires_date exists in NSUserDefaults - update with new expires_date upon renewal completion) or a fresh purchase (expires_date does not exist, either because it was removed upon a previous subscription expiration or the product has never been purchased).

这个问题无关紧要 - 我做的是比较 expires_date 每次应用程序进入前台时,存储在 NSUserDefaults current_date 。如果 current_date 已通过 expires_date ,我会通过我的服务器验证Apple的收据。 Apple将订阅状态返回给我的服务器( 0 表示订阅有效, 21006 表示已过期,就我的应用程序而言,所有其他都是微不足道的)服务器将它转发到我的应用程序。通过这种方式,我的应用程序需要多长时间才能获得续订的警报(也就是说,订阅已经通过Apple技术更新,但我的应用程序还不知道),因为我确定订阅是否已过期或者没有。

This question is irrelevant - what I do is compare expires_date stored in NSUserDefaults to current_date every time the app enters the foreground. If current_date has passed expires_date, I call my server to verify the receipt with Apple. Apple returns the status of the subscription to my server (0 means the subscription is valid, 21006 means it has expired, and all others are trivial as far as my app is concerned) and the server forwards it to my app. In this manner, it doesn't matter how long it takes my app to be alerted of a renewal (aka the subscription has already technically renewed through Apple but my app doesn't yet know) because I know for certain whether the subscription has expired or not.

在沙盒中,续订似乎非常不值得信任。有时我的订阅会续订五到六次(标准,根据Apple的说法),有时一次,有时根本没有。根据记录,7天订阅的续订频率不会超过30天订阅。在沙盒中具有与在实时服务器中相同的可靠性将是很好的,因此我可以相应地编写代码(并且压力更小),但我离题了。我发现的唯一一种确定性和一致性的方式是使订阅提醒我的应用程序他们已经续订的是 expires_date已经过去&&我强行关闭/重新启动我的应用。有时在背景和前景状态之间切换是有效的,但根据我的经验,这不太可靠 - 我觉得这在现场服务器中会更好[更好]。

In the sandbox, renewals seem to be very untrustworthy. Sometimes my subscriptions will renew five or six times (the standard, according to Apple), sometimes once, and sometimes not at all. For the record, the 7 day subscriptions don't renew a lot more often than the 30 day subscriptions. It would be nice to have the same reliability in the sandbox as we do in the live servers so I can write code accordingly (and stress less), but I digress. The only sure-fire and consistent way I've discovered to make the subscriptions alert my app that they've renewed is when expires_date has passed && I force close/relaunch my app. Sometimes toggling between background and foreground states works, but in my experience this is much less reliable - I have a feeling that this would work [better] in the live servers though.

当我注意到 expires_date 已经过去了。因此,如果更新发生在/之前/之后,则无关紧要,因为我的服务器确切地告诉我订阅的状态。

What I do is check with my server (which in turn checks with Apple) when I notice that expires_date has passed. So it doesn't matter if the renew occurs before/after/never, because my server tells me for certain the status of the subscription.

我希望这些信息可以帮助那些遇到同样问题的人!

I hope this information helps others who have the same questions I did!

这篇关于iOS自动续订订阅 - 有关续订过程的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆