【问题标题】:Firebase local notificationsFirebase 本地通知
【发布时间】:2014-08-29 13:56:35
【问题描述】:

当有来自 Firebase 的回调时,是否有可能触发本地通知?我猜我的线程有问题,

[Firebase setDispatchQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)];

【问题讨论】:

  • 没有足够的信息来帮助您。您能否发布更多与您尝试过的本地通知相关的描述信息和代码?
  • 我想在其他用户向 Firebase 发布新消息时触发本地通知。当应用程序移到后台并注意同步数据时,Firebase 会停止吗?

标签: ios firebase localnotification


【解决方案1】:

您可以通过以下方式实现上述功能。

1 ) 当firebase database 发生任何变化时调用observeEventType 方法

2 ) 实现observeEventType 方法如下。

   // Below statement is point to your database.
   let ref = FIRDatabase.database().reference()

   ref.observeEventType(.Value,withBlock:{ (snapshot) -> Void in
            print(snapshot.value)
            // Put your local notification code here...
   })

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-28
    • 1970-01-01
    相关资源
    最近更新 更多