2
votes

We do have functionality for offline group push notification from server end.

Scenario is below :-

Application is open and go to the group message tab. Now send a message to the group so, other users of group will get message i sent.

By closing (kill or in background) the application from ios end they are setting users presence to offline. So once application is closed they will get push notification in mobile.

Issue is by closing the application still i am receiving push notification in mobile even though i read the same message.

From back-end i have set a cron job which runs on server at every 30 seconds and checks the user presence in the group and send push notificaiton to those users who are offline in their mobile.

So is there any way to get last logout timestamp using REST API so i can put condition and check if last user logged in time is less than current time accrodingly push notificaitons will send.

Not able to get last logout time using REST API http://example.com:9090/plugins/restapi/v1/sessions/yourUserName

which outputs :-

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <sessions>
    <session>
        <sessionId>[email protected]/1ae2xq14da</sessionId>
        <username>yourUserName</username>
        <ressource>1ae2xq14da</ressource>
        <node>Local</node>
        <sessionStatus>Closed</sessionStatus>
        <presenceStatus>Online</presenceStatus>
        <priority>0</priority>
        <creationDate>2017-01-18T08:58:01.611Z</creationDate>
        <lastActionDate>2017-01-18T08:58:05.121Z</lastActionDate>
        <secure>false</secure>
    </session>
  </sessions>

By executing above method getting creation date and last action date incorrect.

1) creationDate :- 2017-01-18T08:58:01.611Z
2) lastActionDate :- 2017-01-18T08:58:05.121Z

http://example.com:9090/plugins/restapi/v1/users/yourUserName

Which doesnot output last login timestamp

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<user>
    <username>yourUserName</username>
    <name>yourUserName</name>
    <email>[email protected]</email>
    <properties/>
</user>

We have used REST API Plugin

Any Help would be appriciate.

1
How do you manage presence? Do you explicitly send presence while login-logout?MrPk
@MrPk thanks for having interest. By the way chatting functionality is from ios end so they are managing presence and dealing with server when application will go into background or kill state. if user kills or goes in background application user will be offline.Shashank Shah
By my expirience, if you let Openfire manage by itselft without explicit Presence the offline/online status, Last Activity brokes. Try to send also a Presence when you go background or before kill the app and try what you getMrPk
Glad to let you know that we have done it successfully using user status plugin. This plugin automatically saves the last status (presence, IP address, logon and logoff time) per user and resource to userStatus table in the Openfire database so what i did is compare the message time and logoff time based on this notifications has sent. Thank you for your time and efforts.Shashank Shah

1 Answers

1
votes

User Status Plugin did the job!

User Status Plugin is a plugin for the Openfire XMPP server to save the user status to the database.

This plugin automatically saves the last status (presence, IP address, logon and logoff time) per user and resource to userStatus table in the Openfire database.

Optionally you can archive user status entries (IP address, logon and logoff time) for a specified time. History entries are stored in the userStatusHistory table. The settings for history archiving can be configured on the "User Status Settings" page that you'll find on the "Server" tab of the Openfire Admin Console.

The plugin is available at http://maven.reucon.com/projects/public/user-status

According to the project's Web site, currently this plugin only works with MySQL.

So by putting condition based on logoff time and message time push notifications are sending.