Created
January 19, 2019 09:53
-
-
Save feloy/337d2f1c304890a0495b603834779711 to your computer and use it in GitHub Desktop.
Send a score from Android app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[...] | |
Map<String, Object> doc = new HashMap<>(); | |
doc.put("uid", currentUser.getUid()); | |
doc.put("name", name); | |
doc.put("points", score.getTotalScore()); | |
doc.put("details", score.getDetailsToSave()); | |
doc.put("country", countryCode); | |
FirebaseFirestore db = FirebaseFirestore.getInstance(); | |
db.collection("Score") | |
.add(doc) | |
.addOnSuccessListener(new OnSuccessListener<DocumentReference>() { | |
@Override | |
public void onSuccess(DocumentReference documentReference) { | |
Log.d("MyGame", "Score added to firestore"); | |
} | |
}) | |
.addOnFailureListener(new OnFailureListener() { | |
@Override | |
public void onFailure(@NonNull Exception e) { | |
Log.w("MyGame", "Failed to write score to firestore"); | |
} | |
}); | |
[...] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment