I changed the "new Dictionary<string, Java.Lang.Object>" to "var map = new HashMap();" and used the map.put into insert into Firebase.
Adding document to Cloud Firestore with xamarin.android not working any longer. Can someone help?
Hi, I'm new to Xamarin and have been working on inserting records(documents) to Cloud Firestore. It one point about three days ago it was working without an issue. I was able to add. Now I'm getting error messages. It only happens in xamarin.android, xamarin.ios is still working. Any help would be greatly appreciated.
I get the error: CS1503: Argument 1: cannot convert from 'System.Collections.Generic.Dictionary<string, Java.Lang.Object>' to 'Java.Lang.Object'
See method below:
public bool InsertPost(Models.Post post)
{
try
{
var collection = Firebase.Firestore.FirebaseFirestore.Instance.Collection("Posts");
var postDoc = new Dictionary<string, Java.Lang.Object>
{
{ "UserId", Firebase.Auth.FirebaseAuth.Instance.CurrentUser.Uid },
{ "Title", post.Title },
{ "Detais", post.Details },
{ "PostDate", DateTimetoNativeDate(DateTime.Now) }
};
collection.Add(postDoc);
return true;
}
catch (Exception ex)
{
return false;
}
}
Developer technologies | .NET | Xamarin
1 additional answer
Sort by: Most helpful
-
ExerMine 1 Reputation point
2021-05-01T21:38:59.903+00:00 public bool InsertPost(Models.Post post)
{
try
{
var collection = Firebase.Firestore.FirebaseFirestore.Instance.Collection("Posts");
var postDoc = new Dictionary<string, Java.Lang.Object>
{
{ "UserId", Firebase.Auth.FirebaseAuth.Instance.CurrentUser.Uid },
{ "Title", post.Title },
{ "Detais", post.Details },
{ "PostDate", DateTimetoNativeDate(DateTime.Now) }
};////////////////////////////////////
//collection.Add(postDoc);
// changed to ->
collection.Add(new HashMap(postDoc));return true;
}
catch (Exception ex)
{
return false;
}
}