简体   繁体   English

从 Web 服务器推送通知到 android 应用程序

[英]Push notifications from Web server to android application

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.我正在尝试制作类似 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 .我们的 android 应用程序是用Android-Java制作的,我们还在开发一个网络服务器,它也是用Java编写的,使用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 .一旦客户使用此应用程序(为客户)下订单,我想让推送通知出现在Store-Owner-Application中。 I was thinking about using WebSocket, but is Firebase a great alternative for websocket in this case?我正在考虑使用 WebSocket,但在这种情况下,Firebase 是 websocket 的绝佳替代品吗? I never used neither WebSocket or Firebase before.我之前从未使用过 WebSocket 或 Firebase。 Just asking for some tips and advice.只是要求一些提示和建议。 Thank you:)谢谢:)

in simple cases, Firebase is a much better alternative to implementing it yourself using WebSocket.在简单的情况下,Firebase 比使用 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.这是因为 Firebase 已经有一个耗尽电池的不断打开的套接字来处理它的通知,而且由于大多数应用程序使用它而不是创建一个新的套接字,它有助于节省电池和其他资源。

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.但也有一些例外。Firebase 并不完美,它允许在大部分时间向客户端发送消息,在某些情况下,您的通知会延迟,或者根本不会送达。 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.如果您需要一个简单的 99% 解决方案来发送易于实施且不会浪费电池的推送通知 - Go 和 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.如果您必须完全控制您的通知并需要它们始终交付,请尽快考虑自己实施。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM