【问题标题】:How to get notification in xamarin forms on firebase data change?如何在 xamarin 表单中获取有关 firebase 数据更改的通知?
【发布时间】:2020-04-29 02:37:55
【问题描述】:

例如:当 Firebase 数据库发生变化时在后台获取通知...即插入、删除记录等 可能吗?请让我知道如何实现这一点我是 xamarin 表单的新手。

【问题讨论】:

标签: xamarin xamarin.forms xamarin.android xamarin.ios


【解决方案1】:

试试订阅方法

 var firebase = new FirebaseClient("https://project_id.firebaseio.com/");
            firebase.Child("dataname").AsObservable<datatype>().Subscribe(obs =>
            {


                switch (obs.EventType)
                {
                    case Firebase.Database.Streaming.FirebaseEventType.InsertOrUpdate:
                        break;
                    case Firebase.Database.Streaming.FirebaseEventType.Delete:
                        break;
                    default:
                        break;
                }
            });


【讨论】:

  • 这一行给出错误:firebase.Child("dataname").AsObservable().Subscribe(obs => does not exist in current context
  • @USAMAMALIK 什么是完整的错误。您是否将dataname 替换为数据库名称,将datatype 替换为数据库类型的Type
猜你喜欢
  • 2021-05-03
  • 1970-01-01
  • 2012-09-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-27
  • 1970-01-01
相关资源
最近更新 更多