Hey,
My XMPP-Server (ejabberd) pushs an android client, when the user receives an offline message in the MAM storage, but I think it´s not a good way to this with GCM /FCM.
Reasons:
- The android client (XMPPTCPConnection) is completly disconnected, when the app is closed.
- Push Notifications (using FCM) are not delivered immediately, even the priority is set to ‘high’.
- For each MAM-Message the client has first to login and loads the message (takes 3 - 4 sec.)
The goal is to receive the message immediately like in Telegram, Viber or WhatsApp.
I did some research and found possible solution proposals to do this with the Smack API.
@Flow posted some answers on StackOverflow that NO push notifications are needed.
- https://stackoverflow.com/questions/41819146/android-smack-keep-xmpp-connection-alive-in-sleep-mode
- https://stackoverflow.com/questions/26082731/how-to-create-service-in-android-which-makes-persist-xmpp-connection-with-xmpp-s
I want to try it out how it works…
The idea to make it work is the following:
- Create a
Service
class which is startedSTART_STICKY
- Create a
ServerPingWithAlarmManager
object in the Service class - Listen on connectivity changes
I don´t know when the XMPPTCPConnection’s instantShutdown()
is called. When the MAM message is loaded?
And how to “push” the client that a new MAM message is available? Maybe using a PubSub node?
Is it the right way to get the messages immediately?
Thanks in advance.