public void OnFailure(Java.Lang.Exception e) { OnSendingResult?.Invoke(this, new ResultEventArgs { Result = "Error occured: " + e.Message }); }
public void OnSuccess(Java.Lang.Object result) { var snapshot = (DocumentSnapshot)result; string messageId = FirebaseBackend.FirebaseBackend.GetFireStore() .Collection("do not exits") .Document(Helpers.Helper.GenerateMessageId()).Id.ToString(); DocumentReference documentRef = FirebaseBackend.FirebaseBackend.GetFireStore() .Collection("chats") .Document(conversationId); if (!snapshot.Exists()) { HashMap hashMap = new HashMap(); hashMap.Put(messageId, null); documentRef.Set(hashMap); documentRef.Update(messageId.ToString() + "." + "message_body", body); documentRef.Update(messageId.ToString() + "." + "message_date", DateTime.Now.ToString("dd MM yyyy HH:mm:ss")); documentRef.Update(messageId.ToString() + "." + "from", from); documentRef.Update(messageId.ToString() + "." + "to", to); documentRef.Update(messageId.ToString() + "." + "to_fullname", toFullname); documentRef.Update(messageId.ToString() + "." + "to_image_id", toUrl); documentRef.Update(messageId.ToString() + "." + "from_fullname", Helpers.Helper.GetFullName()); documentRef.Update(messageId.ToString() + "." + "from_image_id", Helpers.Helper.GetImageUrl()); } else { HashMap hashMap = new HashMap(); hashMap.Put(messageId, null); documentRef.Update(messageId, null); documentRef.Update(messageId.ToString() + "." + "message_body", body); documentRef.Update(messageId.ToString() + "." + "message_date", DateTime.Now.ToString("dd MM yyyy HH:mm:ss")); documentRef.Update(messageId.ToString() + "." + "from", from); documentRef.Update(messageId.ToString() + "." + "to", to); documentRef.Update(messageId.ToString() + "." + "to_fullname", toFullname); documentRef.Update(messageId.ToString() + "." + "to_image_id", toUrl); documentRef.Update(messageId.ToString() + "." + "from_fullname", Helpers.Helper.GetFullName()); documentRef.Update(messageId.ToString() + "." + "from_image_id", Helpers.Helper.GetImageUrl()); } OnSendingResult?.Invoke(this, new ResultEventArgs { Result = "Message sent successfuly" }); }