Integration with Push Server

Edit on Github Send Feedback 2021.03 - Current Release

In order to register devices and send push notifications, the Push Server needs to be integrated with server applications. The first application that must communicate with the Push Server is a mobile API application (the one that publishes service specific API for mobile application).

Prerequisites for the tutorial

  • Running PowerAuth Server with available REST interface.
  • Running PowerAuth Push Server with available REST interface.
  • Knowledge of applications based on Spring Framework.
  • Software: IDE, Application Server (Tomcat, Wildfly, …)

Common integration steps

Adding Maven Dependency

In order to be able to implement integration easily, add Push Server client Maven dependency to your pom.xml file:


Prepare a Service Client Configuration

In order to connect to the PowerAuth Push Server, you need to add following configuration:

@ComponentScan(basePackages = {"io.getlime.push"})
public class PowerAuthPushConfiguration {

  public PushServerClient pushServerClient() {
    PushServerClient client = new PushServerClient();
    return client;


Integration With Mobile API

Prepare the Device Registration Endpoint

In order to implement generic device registration, implement a custom registration RESTful Endpoint that calls the Push Server under the hood, for example like so:

@RequestMapping(value = "push")
public class DeviceRegistrationController {

    private PushServerClient pushServerClient;

    private static final Long APP_ID = 1; // Replace by your app ID or use a configuration class

    @RequestMapping(value="device/create", method = RequestMethod.POST)
    public @ResponseBody String registerDevice(@RequestBody Map<String,String> request) {

        // Get the values from the request
        String platform = request.get("platform");
        String token = request.get("push_token");

        // Check if the context is authenticated - if it is, add activation ID.
        // This assures that the activation is assigned with a correct device.
        String activationId = null;
        PowerAuthApiAuthentication authentication = SecurityContextHolder.getContext().getAuthentication();
        if (authentication != null) {
            activationId = authentication.getActivationId();

        // Register the device and return response
        boolean result = pushServerClient.registerDevice(APP_ID, token, MobilePlatform.valueOf(platform), activationId);
        if (result) {
            return "OK";
        } else {
            return "NOT_OK";

The code checks for PowerAuthApiAuthentication instance in the security context and if it is present, it binds the activation ID with the push service token.

Note: We are using ‘dummy’ request (Map<String,String>) and response (String) objects. Replace them with your proprietary classes.

Integrate with Push Producer Applications

Push Producer Application is any application that sends push notification request. The purpose of the producer applications is to call service for push notification sending (single or batch):

// Prepare push message object
PushMessage push = new PushMessage();

// Set push message attributes

// Set push message body
PushMessageBody body = new PushMessageBody();
body.setTitle("Balance update");
body.setBody("Your balance is now $745.00");

// Add custom message data attributes
Map<String,Object> extras = new HashMap<>();
extras.put("customKey", "customValue");
extras.put("customDate", new Date());

// Set the new push message body

// Send single push message
pushServerClient.sendNotification(APP_ID, push);

// Send push message batch
List<PushMessage> messageList = new ArrayList<>();
pushServerClient.sendNotificationBatch(APP_ID, messageList);

Other Tasks

Disabling SSL Certificate Validation

In testing or development environments, you may disable SSL validation by setting an attribute when creating PushServerClient bean. Make sure that this setting is not used in production environment.

public PushServerClient pushServerClient() {
    PushServerClient client = new PushServerClient();
    // whether invalid SSL certificates should be accepted
    if (acceptInvalidSslCertificate) {
    return client;
Last updated on Jun 26, 2020 (19:46) Edit on Github Send Feedback


Mobile token

Powerauth push server