Retrieve Last Logout timestamp for xmpp / openfire users

Overview :

We are not able to find any plug-in in openfire for sending push notification to offline group members.

Therefore, We have used cron job to send push notification and the cron job will run at every 10 seconds. The Cron job will have code to find all the offline group members and send the new messages as push notification to all the offline members.

Problem :

This has solved the group push notification issue but a issue arise that user will get push notification even if user read messages. Please refer below example to understand the problem.

For example :
> One group having three members A,B and C.
> A send messages in the group. B is online and C is offline at that time.
> As B is online at the the time of A sent messages in Group. He will get the messages of Group and he is gone offline right after read the message.
> Now, the cron executed to send push notification to all offline group members. So the cron will find out that B and C both are offline and push notification will send to both users.
> But practically only C should get the push notification as B had already read the group messages.

Solution :

So, to solve the issue we have to compare message timestamp with user’s last logout timestamp and based on it we can restrict push notification to group member who have already read the messages. If user’s last logout timestamp is greater than message timestamp than push notificaion should not sent to that particular user for that particular group message.

To find user’s last logout date we have done research on it and found a plug-in of openfire which stores user’s all sessions’ details presence,login/logout timestamp.

You may also like

Leave a Reply