Mobile chat feature with push notifications, when do I need to click something?

(The next question relates to mobile platforms in general (iPhone, Android, Blackberry).

We integrate chat features into our existing application. I developed a system with the .Net web service and Sql Database for tracking chat messages. Everything works fine as long as the chat window is open.

I need a way to notify the user of a new message when he / she does not view the chat screen (this means that the application is not in the foreground or they are in another section of the application (and not in the chat screen).

Obviously push notifications will be perfect here, but I'm not sure when I should send push notifications.

How does the client sending the message find out if the other guy is viewing the chat screen? Should I just send with each message and receive the receiving device, decide whether it needs to pop up a window or display something in the nofication panel?

It seems that an excessive sound is pressed every time a message is sent. How is this usually done?

Any ideas at all will be appreciated.

Thanks.

+4
source share
2 answers

First of all, keep in mind that your server will act as a broker for all messages transmitted between different chat clients. Here's how it might work:

  • User A initiates a message to User B
  • The message is sent to the server.
  • The server determines that this message is for user B
  • The server initiates a push notification and sends a message to user B

Now why do you need to push each chat message? Because the only way for your users to receive notifications is to poll your server for new messages. A constant survey (to whatever extent you define) is extremely bad in the mobile world due to limited resources (battery, network, etc.)

In a push notification scenario, an application can handle the logic of whether a user is notified of a new message. This means that when user B receives a new message from user A , you decide whether you want to notify B (i.e. bring the application to the forefront) or not. In any case, you want to use push notifications instead of polling.

Similarly, user B does not need to know that user A application (your application) is in the background, so you need to handle this logic accordingly (in your application).

+4
source

Clicking a notification usually applies to the application if it is not in the foreground. This is a way to wake up the application to process a new transaction from the server. Basically, a push notification should be performed if the client is running in the background and a new message is ready to be downloaded from the server. Until a new message is retrieved, if other messages arrive on the server, a push notification should be sent to the application.

A push notification is not required if the application is still running, even if the user is viewing other screens of the application. However, it is important that the thread handles a connection to a server that is patiently awaiting transactions from the server.

One question is, what protocol do you use for messaging ... Is this the OMA IMPS protocol?

0
source

Source: https://habr.com/ru/post/1395461/


All Articles