【问题标题】:Firebase Realtime Database Issue when trying to add item to the database in Xamarin iOS尝试将项目添加到 Xamarin iOS 中的数据库时出现 Firebase 实时数据库问题
【发布时间】:2021-02-14 12:57:55
【问题描述】:

当我尝试将数据推送到数据库时,我收到一条错误消息,提示密钥不能为空或包含“$”、“[”、“]”、“#”等字符。这很奇怪,因为我不是每次都收到此错误,而只是偶尔出现一次。我不明白为什么。有人可以帮助我。谢谢。

       // Convert C# Dictionary to NSDictionary
            var _item = NSDictionary.FromObjectsAndKeys(ItemDict.Values.ToArray()
                                               , ItemDict.Keys.ToArray());

            DatabaseReference newItem = root.Database.GetRootReference().GetChild("Posts").GetChildByAutoId();
            newItem.SetValue(_item); 

【问题讨论】:

    标签: c# firebase-realtime-database xamarin.forms xamarin.ios


    【解决方案1】:

    听起来您的 ItemDict 中的某些值的键包括 $[].#,并且实时数据库中的键中不允许使用这些字符.

    您需要先从键中过滤掉此类字符,然后再将它们传递给 Firebase。

    【讨论】:

      猜你喜欢
      • 2021-07-09
      • 1970-01-01
      • 1970-01-01
      • 2018-03-18
      • 2021-05-24
      • 1970-01-01
      • 2017-05-10
      • 2021-10-04
      • 1970-01-01
      相关资源
      最近更新 更多