消息队列类的目的是什么?我们如何使用它来处理Firebase推送通知?

huangapple go评论60阅读模式
英文:

What is the purpose of MessageQueue class and how do we use it to handle the Firebase push notification?

问题

我正在开发一个用于食品送餐平台的餐厅应用程序。基本上,当客户下订单时,餐厅应用程序将收到一个Firebase通知,然后会弹出一个窗口,持续10秒,以接受或取消订单。在这里,我遇到了一个问题,如果我同时从多个客户那里收到订单,通知只会弹出一次。为了解决这个问题,我尝试开发一个消息队列来处理Firebase推送通知。但是我对它没有清晰的理解,我想知道消息队列类是做什么的,以及如何使用它。我已经阅读了Android MessageQueue类的文档,但我无法完全理解它。我在很多地方都看到过它,但无法理解它的目的。有人可以通过定义MessageQueue的目的并提供一个简单的示例(如果可能的话)来帮助我吗?

英文:

I am developing the Restaurant app for a food delivery platfrom. Basically when a customer placed an order, the Restaurant app will get a firebase notification and there will be a popup for 10 seconds to accept or cancel the order. Here i been facing an issue, if i get orders from multiple customers at the same time, the notification pops up only once. To over come this i tried to develop a message queue to handle the firebase push notification. But the i dont have a clear understanding on it, I want to know what the Message queue class does and also how to use it. I have read the Android MessageQueue class documentation but I am unable to completely understand it. I have seen it in a lot of places but unable to understand its purpose. Can anyone help me by defining the purpose of MessageQueue and also by giving a simple example if possible?

答案1

得分: 1

MessageQueue类在Android中的目的

每当您想要从另一个线程更新一些UI元素(视图元素)时,都可以使用MessageQueue类。也许您正在另一个线程中进行一些繁重的操作,并且希望更新UI元素,但您不能在其他线程中直接更新UI元素,只能在UI线程中执行更改,因此您可以将更改发布到在UI线程中执行。

使用Firebase推送通知。在这里,您可以根据您的主题推送通知,还可以使用FirebaseMessagingService来接收推送通知。

欲了解更多信息,请参阅此链接

英文:

Purpose of MessageQueue Class in Android <br><br>
Whenever you want to update some UI elements (View element) from another thread. Maybe you're doing some heavy lifting in another thread and want to update the UI element, you can't update the UI elements in other threads but the UI thread so you post changes to be executed in the UI thread.

Use Firebase Push Notification. here you can push notification based according to your topic also for receiving push notification use FirebaseMessagingService

for more please refer this

huangapple
  • 本文由 发表于 2020年7月24日 02:54:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/63061251.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定