Android: in-app: check if an item has been purchased

偶尔善良 提交于 2019-12-04 02:33:16

问题


I folloed this tutorial to implement in-app in my application: http://blog.blundell-apps.com/simple-inapp-billing-payment/

The user can now purchase my item (com.myitem) with in-app system. After that, I set in a Shared Preference that the user has been purchased the item.

The problem is if the user uninstalla and reinstall the app. So the question is: how can I check if the user has been already purchased the item?

I know that I should use restore BillingHelper.restoreTransactionInformation(...) on RESTORE_TRANSACTION...but where, and how?

I checked Dungeon example, but it seems to hard and complex to unterstand. There's a simple way to do that?

Thank you


回答1:


Using RESTORE_TRANSACTION is the only way if you use managed purchases. If you use unmanagaed purchases, you can store the purchase state on your own server, but that is hardly simpler. There is nothing complex about RESTORE_TRANSACTIONS: you just fire the command and you get notified with transaction information that is in the exact same format as what you get when you first purchase an item. You should process it in the exact same way, and chances are you already have the code for that in your app. Testing this is somewhat harder, because it doesn't really work with test accounts, and you need a live app. Go over the official documentation again to understand how it works.



来源:https://stackoverflow.com/questions/12239871/android-in-app-check-if-an-item-has-been-purchased

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