使用推送通知的移动聊天功能,什么时候应该推送某些内容?

发布于 2025-01-03 13:10:25 字数 390 浏览 3 评论 0原文

(以下问题适用于一般移动平台(iPhone、Android、Blackberry))

我们正在将聊天功能集成到我们现有的应用程序中。我使用 .Net Web 服务和 Sql 数据库设计了系统来跟踪聊天消息。到目前为止,当聊天窗口打开时,一切工作正常。

当用户当前没有查看聊天屏幕时(这意味着应用程序不在前台,或者它们位于应用程序的另一个部分(不是聊天屏幕)),我需要一种方法来通知用户有新消息。

显然,推送通知在这里是完美的,但我不确定何时应该发送推送,

发送消息的客户端如何知道对方是否正在查看聊天屏幕?消息并让接收设备决定是否需要弹出一个窗口或在通知栏中显示一些内容?

每次发送消息时都推送似乎太过分了,这通常是如何完成的?

任何想法都会非常感谢

(The following question is for mobile platforms in general (iPhone, Android, Blackberry))

We are integrating chat functionality into our existing application. I designed the system with a .Net web service and Sql Database to keep track of chat messages. Everything's working fine so far, when the chat window is open.

I need a way to notify the user of a new message when he/she is not currently viewing the chat screen (meaning either the app is not in the foreground or they are in another section of the app (not the chat screen).

Obviously, push notifications would be perfect here, but I'm not sure when I should be sending pushes.

How would the client sending the message know whether or not the other guy is viewing the chat screen? Should I just be sending pushed with every single message and have the receiving device decide whether or not it needs to pop up a window or display something in a nofication bar?

It seems like overkill to be pushing every single time a message is sent. How is this normally done?

Any ideas at all would be greatly appreciated.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝戈者 2025-01-10 13:10:25

首先,请记住,您的服务器将充当不同聊天客户端之间传递的所有消息的代理。其工作原理如下:

  • 用户 A 为用户 B 发起一条消息,
  • 消息被发送到服务器。
  • 服务器确定该消息是针对用户B的。
  • 服务器发起推送通知并将消息传递给用户B

现在为什么您需要推送每一条聊天消息?因为您的用户获得通知的唯一其他方式是轮询您的服务器以获取新消息。由于资源(电池、网络等)有限,持续轮询(无论您确定的速率)在移动领域极其糟糕

推送通知场景中,由您的应用程序来处理是否在收到新消息时通知用户的逻辑。这意味着当用户 B 收到来自用户 A 的新消息时,您可以决定是否要通知 B (即将您的应用程序带到前台)或不。在任一情况下,您希望使用推送通知而不是轮询。

类似地,用户 B 不一定需要知道用户 A 的应用程序(您的应用程序)位于后台,这就是您需要处理该问题的原因逻辑(在您的应用程序内)适当。

First and foremost, keep in mind that your server will act as the broker for all messages passed between different chat clients. Here's how this could work:

  • User A initiates a message for user B
  • Message gets sent to the server.
  • Server determines that this message is for user B.
  • Server initiates a push notification and delivers the message to user B.

Now why would you need to push every single chat message? Because the only other way for your users to get notified would be to poll your server for new messages. Constant polling (at whatever rate you determine) is extremely bad in the mobile realm due to limited resources (battery, networking, etc.)

In a push notification scenario, it is up to your application to handle the logic of whether the user is notified on receiving a new message. What this means is that when user B receives a new message from user A, it's up to you to decide if you wish to notify B (i.e. bring your app to the foreground) or not. In either scenario, you want to use push notifications instead of polling.

On a similar note, user B does not necessarily have to know that user A's application (your app) is in the background which is why you will need to handle that logic (within your app) appropriately.

破晓 2025-01-10 13:10:25

如果应用程序不在前台,则推送通知通常会应用于该应用程序。它是一种唤醒应用程序以处理来自服务器的新事务的方法。基本上,如果客户端在后台运行并且准备从服务器获取新消息,则将完成推送通知。只要没有获取新消息,如果其他消息到达服务器,就应该向应用程序发送推送通知。

如果应用程序仍在运行,即使用户正在查看应用程序的其他屏幕,则不需要推送通知。然而,重要的是,线程正在处理与服务器的连接,该线程“耐心地”等待来自服务器的事务。

一个问题,您使用什么协议进行消息传递?...是 OMA IMPS 协议吗?

Push notification normally is applied to the application if it is not in the foreground. It is a way to wake-up the application to handle a new transaction from the server. Basically, a push notification is to be done if the client is running in the background and a new message is ready to be fetched from the server. As long as the new message is not fetched, if other messages arrive on the server, a push notification should be sent to the application.

Push notification is not necessary if the application is still running even if the user is viewing other screens of the application. It is however important that a thread is handling the connection to the server which is "patiently" waiting for transactions from the server.

One question, what protocol are you using for the messaging?.. Is it OMA IMPS protocol?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文