I'm an android developer learning to write my app for iOS using swift. I'm unsure how to run multiple firebase (firestore and realtime database) write tasks asynchronous and return a completion handler. In android I use the Tasks API and have it written as follows:
Task<Void> firestoreTask = firestoreDB.getDocument("users/someId").update("name", "some name");
Task<Void> realtimeTask = realtimeDB.child("users/someId/name/").setValue("some name");
Tasks.whenAll(firestoreTask, realtimeTask).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
// if both tasks are successful
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// if at least one of the two task fails
}
});
I can't seem to figure out how to write such a task in swift. Can someone please point me in the right direction? Thank you.