从 Web 服务器推送通知到 Android 应用

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

Push notifications from Web server to android application

问题

大家好,正在查看这个问题的所有人。我认为这个问题可能相当抽象,但是通过谷歌搜索我找不到正确的答案。

我正在尝试制作一个类似星巴克Siren-Order的应用程序。

我们的Android应用程序是用Android-Java制作的,我们还正在开发一个Web服务器,也是用Java编写的,使用Spring-MVC

一旦客户使用这个应用程序(为客户)下订单,我想在Store-Owner-Application中显示推送通知。我考虑使用WebSocket,但在这种情况下,Firebase是否是WebSocket的一个很好的替代品?我以前都没有使用过WebSocket或Firebase。只是想要一些提示和建议。谢谢 从 Web 服务器推送通知到 Android 应用

英文:

Hello to everyone who is viewing this question. I think this question might be quite abstract, but I couldn't find the correct answer by googling.

I am trying to make an application like Starbucks Siren-Order.

Our android applications are made in Android-Java, and we are also developing a web-server which is also
written in Java, using Spring-MVC.

Once a customer makes an order using this application(which is for customers), I want to make push notifications appear in Store-Owner-Application. I was thinking about using WebSocket, but is Firebase a great alternative for websocket in this case? I never used neither WebSocket or Firebase before.
Just asking for some tips and advice. Thank you 从 Web 服务器推送通知到 Android 应用

答案1

得分: 4

在简单的情况下,Firebase是一个比自己使用WebSocket实现更好的选择。

这是因为Firebase已经拥有一个不断开的耗电量的开放式套接字来处理其通知,由于大多数应用程序使用它而不是创建新的套接字,它有助于节省电池和其他资源。

不过也有一些例外情况...
Firebase并不完美,它允许在大多数情况下向客户端发送消息,但在某些情况下,您的通知可能会延迟或根本无法传递。
例如:

  1. 如果电池电量低
  2. 如果设备最近接收了许多推送通知

如果您需要一个简单的99%解决方案来发送推送通知,而且易于实施并且不会浪费电量 - 选择Firebase。

如果您必须对通知拥有完全控制权,并且需要它们尽快全部送达,可以考虑自行实现。

英文:

in simple cases, Firebase is a much better alternative to implementing it yourself using WebSocket.

That's because Firebase already has a battery draining constantly open socket to handle its notifications, and since most apps use it rather than creating a new socket, it helps conserve battery and other resources.

There are a few exceptions though..
Firebase isn't perfect, it allows sending messages to the client most of the time, and in some cases, your notification will be delayed, or won't get delivered at all.
For example:

  1. If the battery is low
  2. if the device received many push notifications recently

If you need a simple 99% solution to sending push notifications that is easy to implement and won't waste battery - Go with Firebase.

If you have to have full control over your notifications and need them delivered all the time, as soon as possible, consider implementing it yourself.

huangapple
  • 本文由 发表于 2020年8月18日 14:07:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/63462776.html
匿名

发表评论

匿名网友

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

确定