Why don't Android C2DM push messages always arrive?

I created a functional C2DM application, and as a rule, it works very well, and push messages arrive quickly. However, I find this pretty regularly when I first launch the application or put it back in focus, no messages arrive.

They are definitely sent successfully (I get a 200 response), and the message format is certainly right (sending the same message later works fine). The malfunction can last for a few minutes, and then suddenly starts working again and works sequentially after that.

However, even after it starts working, the old messages seem to have disappeared and never come. Messages certainly don't arrive - I have extensive logging that highlights any C2DM messages that come.

I fully understand that C2DM never guarantees delivery, so I expect some messages to fail, but in my experience, in some cases this just doesn't work. I obviously want to understand that this is what I am doing wrong in my application or in the C2DM service itself.

What could cause C2DM to not be able to send messages? If messages cannot be delivered, why does the C2DM server not try to complete the queue again? Related - should I get a new registration identifier only when the application is launched for the first time or is updated every time the application is launched? I am currently doing the latter (in application, not in action).

+4
source share
2 answers

I realized that I made a student mistake. I corresponded with C2DM every time the application started. This process sometimes takes several seconds, and during this time the application will not receive push messages sent to the old registration identifier. This explains why push messages were most likely not received immediately after the application started.

The solution was to ensure that the registration identifier is only requested if the application is not already installed. Push messages are now much more reliable.

+10
source

This is most likely the correct behavior. Messages are not guaranteed for delivery at all. Directly.

Most likely, this is that the connection between your phone and Google servers is dropped, and it takes a little time to restore.

+1
source

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


All Articles