Firebase:即使应用退出,也要收听ChildEventListener [英] Firebase: Listen ChildEventListener even if app exits

查看:145
本文介绍了Firebase:即使应用退出,也要收听ChildEventListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 iOS 应用程序,并希望使用Firebase实时数据库来实现推送通知等行为。



如果我的应用正在监听某个firebase节点,并且在节点更新的情况下,我会向用户发送本地推送通知。 b

问题是,如果应用程序没有运行,即用户已经杀死它,我的应用程序是否会继续监听特定的节点?
我想,在Android中,我们已经支持这样的,正如在这个链接(链接)。



我们可以在iOS中实现相同的行为吗?如果不是,可以选择什么?

感谢

更新

1-在iOS应用程序中没有像在本地触发推送通知一样的事情。我想实现远程通知的行为,这是不能做到的。

<2->至于听某个事件,当应用程序不在前台或后台时,不能完成。


如果一个iOS应用程序在内存中被杀死/不存在,你就无法做任何事情。



但是,如果应用程序在后台,并且存在于内存中,则可以执行一些任务。
您可以使用后台获取请求在这种情况下。

在Android中,有 Services 即使应用程序被终止也能运行。但在iOS上,没有这样的事情。



您可以在根视图控制器中添加 Firebase ,并执行后台获取请求以继续在应用程序处于后台时观察数据。


I'm working on an iOS application, and want to achieve behavior like push notifications using firebase real time DB.

In case my app is listening to some firebase node and i'll send local push notification to the user in case that node is updated.

The issue is, if the app is not running i.e. user has killed it, will my app continue listening to that particular node? I guess, in Android we've support like this, as explained in this link (Link).

Can we achieve the same behavior in iOS. If no, what can be the alternative?

Thanks

Update:

1- There's nothing like triggering push notifications locally in iOS app. I wanted to achieve remote notification's behavior and that can't be done.

2- As far as listening to some event is concerned, it can't be done when app is not in foreground or background.

解决方案

You can’t do anything if an iOS app is killed/not present in memory.

However, you can do some tasks if app is in background, and is present in memory. You can use background fetch request in this case.

In Android, there are Services which run even when the app is killed. But on iOS, there is no such thing like this.

You can add Firebase observers in your root view controller, and implement background fetch request to continue observing data when app is in background.

这篇关于Firebase:即使应用退出,也要收听ChildEventListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆