Unified Push just got more Unified

You probably know that we have a Unified Push server that enables you to notify multiple clients (e.g. Apple, Android and Web) using the same notification. We have had requests in the past to add Java client. I thought how hard could it be and had a go at it.

So for the web we use Simple Push, that is based on the work that Mozilla did. Our implementation of the Simple Push server could also enable ‘normal’ Java clients to receive push notifications. We looked for a Java web socket client library to base this on. And because our Simple Push server is also made in Java I could even reuse code for the protocol.

This is how it works, you connect to the Simple Push server and then register a channel:

  SimplePushClient client = new SimplePushClient("ws://localhost:7777/simplepush/websocket");
  client.connect();
  client.register(new RegistrationListener() {
    @Override
    public void onRegistered(String channelId, String simplePushEndPoint) {
    }
  });

This way you could also just use simple push in your Java application without Unified Push, but if you also want to use Unified Push your RegistrationListener is a good place to register your endpoint so that it will get called for unified push notifications:

...

  public void onRegistered(String channelId, String simplePushEndPoint) {
      final PushConfig config = new PushConfig();
      config.setDeviceToken(channelId);
      config.setSimplePushEndpoint(simplePushEndPoint);

      unifiedPushClient.register(config);
  }

With this client the Unified Push just got more Unified, try it out and let us know what you think

*****
Written by Erik Jan de Wit on 15 January 2014