Java for firebase: default value for a new user

Viewed 29

EDIT (because of duplicate issue)

The scope of this is to give non existent users of the app some free credits!

And in order to prevent receiving these credits by swiping the data of the app or reinstalling, I need to get the devices ID tracked.

So maybe there is a method to check whether the device ID (document ID) already exists in the dB.

I would rather prefer having this done on the non compromised Serverside since an app could be hacked or altered.

So, that was my intention. Is that a good approach?

here a JAVA snippet I use:

// Create a new data set
    val user = hashMapOf(
            "device" to deviceID,
            "cups" to numcups
    )

// Add a new document with a defined ID
    db!!.collection("users").document(deviceID)
            .set(user)
            .addOnSuccessListener { documentReference ->
                Log.e(TAG, "DocumentSnapshot added ")
            }
            .addOnFailureListener { e ->
                Log.e(TAG, "Error adding document", e)
            }
0 Answers
Related