0
votes

It seams like to work with chat application, using openfire and smack there can be two ways below,

First Way

Smack makes a connection with the openfire server and it can receive and send updates to the server as long as its connected to the openfire server. In case its not connected, theres a plugin on openfire which keeps the messages offline, and send them once the client is connected again. In this scenario to receive all messages,

1.1 Device should only disconnected from the openfire in case if it don’t have internet.

1.2 User is sign out

1.3 Device is offline

If connection goes disconnected with the server in any other case this cause messages loss. Currently application is working with this architecture. Problems with this method:

The major problem for this is if due to any crash, or problem application gets completely killed, and its not alarm manager task also gets killed. App didn’t restart until the application opens again. Second problem with this is, its consuming battery due to continuous process On updated OS application goes in deep sleep, doze mode, ulta power save mode, background Second Way

Second Way:-

Smack makes a connection with the openfire server and it can receive and send updates to the server as long as its connected to the openfire server until the application is in foreground. As soon as this goes in background the application will completely disconnect from the server. In this case as application is offline openfire have to send all the messages to the Firebase server, same application listens for the firebase notifications and when it receives the notification from firebase it reconnects to the openfire and gets the message and display or shows the message directly from firebase (in this case this record goes to the firebase server as well). Application receives that notification from the gcm and then need to manage in application about message delivery etc.

Problems

I want to know that second way is better then anyone has openfire custom plugins for notification?

1

1 Answers

0
votes

Push notifications requirement is very common in Openfire but no proper solution available openly.

Regarding Second Way, Yes that seems fine if it's working for you. You can leverage firebase capabilities for this.

Regarding message loss, you must start using Stream Management (XEP-0198) to avoid it.