14

I really tried to find a solution to this problem but didn't. There are some threads related to this concept, but I didn't find a comprehensive solution.

I have a server with Openfire which sends messages. When both users are online, there is no problem. However, when a user is offline I would like to send a push notification, as in Whatsapp. I heard that Whatsapp and other IM apps use a modified version of ejabber to send push notifications, but couldn't find out how.

One possibility is to use GCM, but I am not sure if this is the right way to go. Also I would like to avoid polling, for the sake of not draining battery life.

Does anyone know some solution to this or has an example?

Eran
  • 387,369
  • 54
  • 702
  • 768
Max
  • 572
  • 2
  • 6
  • 23

3 Answers3

11

I am studying the openfire and found some good options that I would like to share with you. I found a plugin in github and i will test it this week. It seems that will be a good solution to your goal and to my: https://github.com/meisterfuu/Openfire-GCM/

Another option is to use CallbackOnOffline Plugin that calls a specified URL with To and From parameters. This url could be a endpoint in your web service, and with that data (To and From) you could get the associated Id for push in your base, and did a push.

https://www.igniterealtime.org/projects/openfire/plugins.jsp

Lucas Ferraz
  • 4,112
  • 2
  • 18
  • 23
2

Well, you could use GCM with XMPP. The new GCM Cloud Connection Server allows you to use the XMPP protocol for a bidirectional (Cloud to Device and Device to Cloud) communication between your server and your Android application.

The GCM Cloud Connection Server (CCS) allows third party servers to communicate with Android devices by establishing a persistent TCP connection with Google servers using the XMPP protocol. This communication is asynchronous and bidirectional.

Eran
  • 387,369
  • 54
  • 702
  • 768
  • I will give it a try. I see how this might me be a good solution. Once your solution has worked for me I will accept your answer :) – Max Jun 02 '13 at 12:14
  • Well, it's worth a try, but don't forget it's a trial feature, so it may not be ready yet for production. – Eran Jun 02 '13 at 12:44
  • I was hoping to avoid using GCM, since a google account was needed on the device to receive a push notification, however I see this as the only option at the moment. Thanks again for your answer. – Max Jun 04 '13 at 13:26
-3

In openfire its done automatically, messages will be recieved by the user when the user gets online. So no worries send message to an offline user and when the user comes online message will automatically pushed to the user.

amrinder007
  • 1,455
  • 1
  • 12
  • 13
  • Well thats true, however I would like to make a Instant Messenger, which requires a push notification in the case the user is offline. I want the user to be informed once he was sent a message (a push notification). – Max Jun 04 '13 at 13:23
  • 1
    Why you don't run a background service and keep connection to OpenFire? – Lin Yu Cheng Oct 01 '13 at 03:22