Android In-App-Purchase, how to check if user have purchased one item

前端 未结 4 1067
醉梦人生
醉梦人生 2021-02-13 01:20

is that OK and safe to set a value in SharedPreference to flag that the user have purchased this item? What if user hack this value in SharedPreference. Or I need to connect IAP

4条回答
  •  孤城傲影
    2021-02-13 02:11

    From my experience I can assure you of one thing.

    ** In fact it's bad to put a flag with a bool saying if it's premium or not **.

    • What I do is obfuscate the shared code
    • After I create some strange strings or numbers that only identify through the code inside the app if the user is a premium user.
    • Along with this, except for a numeric code within the database that identifies the type of purchase. So by checking both I can make sure the user is premium.

    At this point if they want to cheat me with the root of the phone they should first understand how the code of my app works and then understand where to interact, because if only the shared preferences change, nothing will change and they will be whipped.

    ** This doesn't translate to high security, but at least the security level is higher and the root won't be able to get a reward that easily. Also because they should understand what are the exact codes to insert in the shared, in the database and look for them by removing the obfuscation. I honestly don't think it's worth it for them. **

提交回复
热议问题