Question

I am using a custom php webserver for an im program to send push messages, for now i can send push notifications to mobile phone but i am not sure about how to use it properly.

By this i mean should i send all messages as push notifications, is it possible to do that? Is there any limitations about push notification's size? Or should i start a timer to check new messages after first notification and finish the timer when the activity is closed? So what would be the most proper way to get instant messages from the server?

Was it helpful?

Solution

For Android the limitation on the push notification size is 4k. If your messages are smaller than that, you can use push notifications for sending all the content.

However, delivery of push notifications is not guaranteed, so it's a better practice to use if as a means for the server to notify the app that new data is available, especially when it's not running in the foreground. The app then calls the server to retrieve the data.

When the app is in the foreground, you can poll the server periodically for new data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top