在我问这个问题之前,我已经浏览了 Android In-App billing documentation ,以及 StackOverflow 上的一些类似问题,例如 this .另外我猜这个问题可能会被关闭或否决,因为它不是一个直接的编程问题并且本质上是主观的。但是,还是这样。
实现工作正常。我的问题是什么是在本地存储应用内购买的好方法。在我的例子中,只有一个一次性解锁项目可以解锁应用程序的全部功能,并且不会过期或被消耗。
Shared Preferences 对于盗版来说似乎有点太容易了。尽管查询 Google Play 工作正常并且看起来相对安全,但它是否足以依赖?由于文档建议异步进行调用,因此为解锁功能付费的用户可能必须等待才能访问解锁功能,这听起来不是一个好主意。此外,当 GP 缓存被清除时,它需要比平时更长的时间(这可能是一种罕见的情况)。
但是看到这么多的应用和开发者,我想知道其他开发者是如何处理的?
最佳答案
实际上,我认为您的问题会因为几个不同的原因而被关闭,但我会给您一些见解。
根据产品的性质和其他一些因素,您有几种选择。
- 如果产品在整个生命周期内有效,或者根据时间(即时,一年更新)有效,您可以依赖 google play,这可能很好。
- 如果产品是用户将在应用程序内以不同方式花费的东西,例如游戏内货币、额外生命等,您应该将其保存在本地、sqlite 数据库或远程数据库中,如果您想用一台服务器来集中一些服务。
如果您查看指南的“消费购买”部分 purchase iab products你可以阅读:
Once an item is purchased, it is considered to be "owned" and cannot be purchased again from Google Play while in that state. You must send a consumption request for the item before Google Play makes it available for purchase again. All managed in-app products are consumable. How you use the consumption mechanism in your app is up to you. Typically, you would implement consumption for products with temporary benefits that users may want to purchase multiple times (for example, in-game currency or replenishable game tokens). You would typically not want to implement consumption for products that are purchased once and provide a permanent effect (for example, a premium upgrade).
对于消耗品:
It's your responsibility to control and track how the in-app product is provisioned to the user. For example, if the user purchased in-game currency, you should update the player's inventory with the amount of currency purchased.
Security Recommendation: You must send a consumption request before provisioning the benefit of the consumable in-app purchase to the user. Make sure that you have received a successful consumption response from Google Play before you provision the item.
无论如何,我建议在任何范围内跟踪用户购买的所有产品以及他自己拥有的所有特权,因为它更快,并且它可能对其他一些事情有用,例如自定义统计信息,报告等
关于android - 存储应用内购买的最佳方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21225252/