Abdul Wasae Abdul Wasae - 1 year ago 104
Android Question

Keep count of consumable in-app purchases using Firebase Realtime Database

My android app features 'slots'

  • Many can be bought (should be non-consumable in-app purchase)

  • I must still keep track of how many slots the user owns (should be consumable in-app purchase)

  • I don't want to incorporate user sign-up/sign-in requirement

  • I want the count of slots to be immediately available to my app (local caching feature of play store)

This was the predicament that I have been into as I have asked here

My Solution (so far):
The solution that I had decided up til now was that I will make several finite non-consumable items (like first-slot, second-slot ... etc). It's not the best solution.

Just recently I came to know about Firebase Realtime Database. I wanted to ask the experts if I could use Firebase Realtime Database for storing the slot counts the way I want, reliably, and without having the users to ever need to sign-up? I might be able to cater for the immediate and reliable retrieval of my data by using the
setPersistenceEnabled (boolean isEnabled)
of my Firebase database instance, as documented here

I just wanted to be sure, before I moved ahead, whether I am on the right path?

Answer Source

I contacted Firebase Support and it turns out that i CANNOT do that without implementing some sort of Account keeping per user.

Here is the actual reply:

I have been meaning to store count of a consumable in-app item for every user persistently. Google play does not allow me to do that unless it is a non-consumable. I wanted to know if using firebase real-time database automatically keeps the data linked to the android users' google account?

Currently, there's no behavior of automatically handling the user information or custom data associated with Google account when using Firebase Realtime Database. You have to create your data linking module associated with the user Google accounts and attach it with the associated Firebase Realtime Database node of the user.

Is the data stored in the realtime database automatically per every user? If the user uninstall and then reinstalls, will the data remain?

You need to create your module in handling the data of the user using Firebase Realtime Database or with your Server API. Note: Firebase Realtime Database persistence/cache will be removed once the app is uninstalled.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download