[英]How to store subscription data for Android in-app billing?
I'm trying to implement in-app billing, where the only thing my app sells is a monthly subscription. 我正在尝试实施应用内结算,我的应用程序销售的唯一内容是每月订阅。 I've gone pretty much copied the Dungeons example that Android provides and it works, but it seems overly complicated for the one thing I have to sell (and I know I shouldn't be copying it anyway).
我已经完全复制了Android提供的Dungeons示例并且它可以工作,但是对于我必须销售的一件事来说似乎过于复杂(我知道我不应该复制它)。
The Dungeons example has a PurchaseDatabase class that keeps track of all of the user's purchases. Dungeons示例有一个PurchaseDatabase类,用于跟踪用户的所有购买情况。 Since there is only one purchase in my app, rather than having a database, it seems like it would make more sense to just have something like a SharedPreference/boolean "isPurchased" and update/check for that when I start up the app... Now I don't really know much about security, but that just seems to ring warning bells and would probably be very hackable.
由于在我的应用程序中只有一次购买,而不是拥有一个数据库,所以当我启动应用程序时,似乎更像是一个像SharedPreference / boolean“isPurchased”并更新/检查的东西。现在我对安全性并不是很了解,但这似乎只是敲响了警钟,可能会非常难以理解。
So, how should I store/restore this one piece of data? 那么,我该如何存储/恢复这一段数据呢? What do I need to save and keep track of, anyway?
无论如何,我需要保存和跟踪什么?
Edit: Found this In-app billing. 修改:找到此应用内结算。 How to store information that user has paid?
如何存储用户已付费的信息? .
。 It would seem that I should use a SharedPreference, but this question still stands: do I just save a boolean "isPurchased" or should I keep track of orderId, developerPayload, etc?
看起来我应该使用SharedPreference,但这个问题仍然存在:我只是保存一个布尔“isPurchased”还是应该跟踪orderId,developerPayload等?
If you just save a flag in shared preferences, any user with a rooted device can flip the flag at will and be 'subscribed' without paying. 如果您只是在共享首选项中保存一个标志,那么任何拥有root设备的用户都可以随意翻转该标志并在不付款的情况下“订阅”。 So you should at least do some obfuscation.
所以你至少应该做一些混淆。 Here's a sample way to do it.
这是一个样本方法 。 Additionally, there is an API to check for subscription state, so you should check periodically to make sure the subscription is valid.
此外,还有一个用于检查订阅状态的API ,因此您应定期检查以确保订阅有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.