Git Product home page Git Product logo

aerogear-unifiedpush-java-client's Introduction

aerogear-unifiedpush-java-client

A Java API for sending Push Notifications to the AeroGear UnifiedPush Server. For more information, please visit the Java Sender Tutorial for example usages.

Getting started

Add the following dependencies to your pom.xml file:

    <dependency>
         <groupId>org.jboss.aerogear</groupId>
         <artifactId>unifiedpush-java-client</artifactId>
         <version>0.5.0</version>
    </dependency>

    <!-- RestEasy's Jackson Plugin -->
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jackson-provider</artifactId>
        <version>2.3.2.Final</version>
    </dependency>

Usage

Create a JavaSender:

JavaSender defaultJavaSender =
  new SenderClient("http://localhost:8080/ag-push");

To connect via proxy:

JavaSender defaultJavaSender = new SenderClient.Builder()
                .rootServerURL("http://localhost:8080/ag-push")
                .proxy("proxy.example.com", 8080)
                .proxyUser("proxyuser")
                .proxyPassword("password")
                .proxyType(Proxy.Type.HTTP)
                .build();

Send a message

Construct a UnifiedMessage using the Builder :

 UnifiedMessage unifiedMessage = new UnifiedMessage.Builder()
                .pushApplicationId("c7fc6525-5506-4ca9-9cf1-55cc261ddb9c")
                .masterSecret("8b2f43a9-23c8-44fe-bee9-d6b0af9e316b")
                .aliases(Arrays.asList("john", "maria"))
                .alert("Hello from Java Sender API!")
                .sound("default")
                .build();

Create a callback

 MessageResponseCallback callback = new MessageResponseCallback() {

            @Override
            public void onComplete(int statusCode) {
              //do cool stuff
            }

            @Override
            public void onError(Throwable throwable) {
              //bring out the bad news
            }
        };

Send the message

defaultJavaSender.send(unifiedMessage, callback);

You can also omit the callback

defaultJavaSender.send(unifiedMessage);

Known issues

On Java7 you might see a SSLProtocolException: handshake alert: unrecognized_name expection when the UnifiedPush server is running on https. There are a few workarounds:

  • JBoss' standalone.xml configuration file:
<system-properties>
   <property name="jsse.enableSNIExtension" value="false"/>
</system-properties>
  • in the Java app, that is using the Java Client SDK: System.setProperty("jsse.enableSNIExtension", "false");
  • Or via commandline argument: -Djsse.enableSNIExtension=false

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.