GroupChat Push Notification on XMPP

2019-01-29 08:31发布

问题:

We are developing an xmpp application on IOS and Android. We are using ejabberd as the xmpp server and we are also using mod_interact (https://github.com/adamvduke/mod_interact) to inform our webservers to send push notifications to clients for their offline messages: Flow is like this:

  1. Sender sends the message to ejabberd
  2. Ejabberd receives the message and check if the receipant is online
  3. If the receipant is offline ejabberd saves the offline message
  4. mod_interact works when an offline message received by ejabberd and deliver the message to our webservers
  5. Web server finds the push notification informations about clients and sends the push notification

Its working very well on 1 to 1 chat. But in group chat(MUC) mod_interact doesnt work and I cannot send push notification to group receipants. Do you know any other solutions to fix that problem on both 1 to 1 and group chat.

Thanks

回答1:

Look into ejabberd_mod_offline_post, it supports both one2one and MUC.

  1. First config the Room must be a Member-Only room, and add all users as members right after you created it, so that be able to get a total.
  2. Add above model into ejabberd models.
  3. Implement a Callback Service to handle the callback post.

The idea is when User go offline:

  • In one-to-one case, offline_message_hook will be raised
  • In MUC case, muc_filter_message will be raised, and any one not Presence-Available is offline.