I am migrating from Firebase Realtime Database to Cloud Firestore. Previously, I would .push() under the Realtime Database, and I would get the key of the .push() as follows:
final String key = mBaseRef.child("ABC").push().getKey();
It does not appear this method is available under the new Cloud Firestore. I am trying as such:
mStoreBaseRef.collection("ABC").add(pollMap).addOnCompleteListener(new OnCompleteListener<DocumentReference>() {
@Override
public void onComplete(@NonNull Task<DocumentReference> task) {
String key = String.valueOf(mStoreBaseRef.collection("ABC").document().getId());
Log.v("KEY", key);
Toast.makeText(getApplicationContext(),key,Toast.LENGTH_LONG).show();
}
}
The log simply is not returning the key that was created.