Monthly Archives: December 2014

The UnifiedPush Java Sender Forge Addon

The purpose of this post is to show how easy it is to integrate the UnifiedPush Java Sender into an existing JEE application. As a reminder, the UnifiedPush Java Sender is a library to send unified push messages to an UnifiedPush Server instance that will then submit ¬†this notification to the different vendors networks (GCM, WNS, APNs etc …). The Java Sender will typically be used in a backend system that needs to interact with a mobile application.

JBoss Tools and Forge

We will be using JBDS (JBoss Development studio) that also ships Forge, a powerful RAD tool. Forge can be extended with “Addons” and since the Unified Java Sender 1.1 there is a dedicated addon for it !

Install the UnifiedPush Java Sender Addon

If you are using the Forge console :

 addon-install-from-git --url

If you are using Forge tools inside JBDS :


Set up the UnifiedPush Addon

Let’s imagine we want to add a Push feature to an existing JEE Web Application, the first thing to do is to setup the addon :

- If you are using the forge console :


You will have to enter 3 fields :

Server URL:
PushApplication id:  123456789
Master Secret:

You can also pass directly the options with the command like :

unifiedpush-setup --serverURL --pushApplicationId 123456789 --masterSecret mypassword

- If you are using Forge Tools :


The Java Sender is now ready to be used ! The dependency has been pulled in and a pushConfiguration.json file has been generated and placed in your resources folder (“/META-INF/pushConfiguration.json”).

Now in your project you could do :

PushSender defaultPushSender = DefaultPushSender.withConfig("META-INF/pushConfig.json").build();

And then to send a message :

UnifiedMessage message = UnifiedMessage.withMessage().alert("Hello 1").build();

Generate the Sender Service

Instead of using directly the Java Sender, you can also let the addon generate a service that will wrap the Java Sender.

- With the console, just run  :


- With Forge Tools just search for the “unifiedpush: Generate Service” command

You will notice that an interface and its implementation, has been generated.

You can now inject this service anywhere you want, for instance :

private SenderService senderService;

public Response create(Message entity) {
  UnifiedMessage message = UnifiedMessage.withMessage().alert(entity.getContent()).build();
  return Response.Ok().build();


Let’s conclude this by a short screencast describing all the steps mentioned before :