在应用程序自动更新订阅 [英] In app auto-renewable subscriptions

查看:90
本文介绍了在应用程序自动更新订阅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于关于iTunes订阅的第100个问题感到抱歉,但我仍有一些疑问。

Sorry for the millionth question about iTunes subscriptions, but I still have a few doubts.

基本上我在我的应用程序中实现自动续订订阅我想要确保我做对了以下列出了我想出的步骤:

Basically I'm implementing auto-renewable subscriptions in my app and I want to make sure I got it right. Here's a list of steps to take that I came up with:


  • 每当用户购买订阅时,将收据发送到服务器进行验证它是


    • 如果收据有效,请将其保存在数据库中


    • if所以,检查商店是否在订阅开始日期到过期日期的日期范围内添加了新商品


      • 如果有,请通知用户关于那些项目,并将它们标记为可免费下载

      这些步骤是否正确?如果是这样,为什么Apple医生说:

      Are these steps correct? And if so, why does the Apple doc say:




      在大多数情况下,您的iOS客户端应用程序不需要更改。事实上,您的客户端应用程序现在变得更加简单,因为您可以使用相同的代码来恢复自动更新订阅,就像恢复非消耗性产品一样。 恢复事务中对此进行了描述。您的应用程序会在续订订阅的每个时间段内收到单独的事务;您的申请应单独验证每张收据。

      In most cases, your iOS client application should not need to change. In fact, your client application is now made simpler, as you can use the same code to recover auto-renewable subscriptions as you do to recover nonconsumable products. This is described in "Restoring Transactions."Your application receives a separate transaction for each period of time where the subscription was renewed; your application should verify each receipt separately.



      给我看看起来这需要一些代码来处理我提到的所有各种情况。或者我完全错了。我是吗?

      To me it looks like this needs some code to handle all the various cases I mentioned, instead. Or I'm totally wrong about it. Am I?

      另外,我如何知道订阅到期日期?我无法找到在任何地方获取此信息的方法。我应该在自己的数据库中保存吗?

      Plus, how do I know about the subscription expiration date? I can't find a way to get this information anywhere. Am I supposed to save this on my own database?

      更新:

      自从我发布这个问题以来,我已经找到了一些东西。如果我错了,请随意纠正我。

      I've figured out a few things since I posted this question. Feel free to correct me if I'm wrong.

      首先,我想我应该在我自己的数据库中存储订阅的长度,因为正如Apple的文档所述,你无法在任何地方检索它通过Apple的网络服务。实际上,每个订阅长度都有不同的产品标识符,因此您应该有办法将产品标识符转换为订阅长度。

      First of all I guess I'm supposed to store the length of the subscription somewhere on my own database, because as stated on Apple's docs, you cannot retrieve it in any way through Apple's web services. In fact, each subscription length has a different product identifier, so you should have a way to convert a product identifier to a subscription length.

      此外,Sylvian 已发布关于他实施自动续订订阅的详细信息,所以至少我知道我的思考没有太多缺陷。

      Also, Sylvian has posted details about his implementation of auto-renewable subscriptions, so at least I know my thinking wasn't too much flawed.

      现在唯一的问题是:我怎么知道用户有有效的订阅?我可以将这些信息存储在我的服务器上,是的,但是如何将用户与已完成的交易相关联?我应该保存设备的UDID吗?

      Now the only problem is this: how do I know that an user has a valid subscription? I could store this information on my server, yeah, but how do I associate an user with a completed transaction? Should I save the device's UDID?

      推荐答案

      我想我找到了一个解决方案。它不需要额外的用户名/密码,它似乎正在工作。

      I think I found a solution. It doesn't require an additional username/password and it seems to be working.

      注意:如果您认为这是不合适的,请在评论中解释原因。谢谢。

      Note: If you think this is inappropriate, please explain why in the comments. Thanks.

      基本上,每当用户购买订阅时,我都会根据我的服务器验证收据,并将收据数据存储在用户默认值中。然后,当应用程序打开时,或者每当我需要检查订阅是否仍然有效时,我从用户默认值中检索以前保存的收据数据并对服务器进行验证。

      Basically, whenever an user buys a subscription, I validate the receipt against my server and store the receipt data in the user defaults. Then, when the app is opened, or whenever I need to check if the subscription is still valid, I retrieve the previously saved receipt data from the user defaults and validate it against the server.

      我的webservice只返回订阅是否仍然有效或已过期,以及其他一些相关信息,如订阅长度。为此,它只是像往常一样查询iTunes服务器,并检查状态响应是否为非零。 21006 表示订阅已过期。

      My webservice just returns whether the subscription is still valid or has expired, plus some other related information such as the subscription length. To do this, it just queries the iTunes server as usual, and checks if the status response is nonzero. 21006 means that the subscription has expired.

      这篇关于在应用程序自动更新订阅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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