Giter Club home page Giter Club logo

aerogear-unifiedpush-java-client's Introduction

AeroGear Unified Push Java Client

Build Status Maven Central Javadocs License

A Java API for sending Push Notifications to the AeroGear UnifiedPush Server.

Project Info
License: Apache License, Version 2.0
Build: Maven
End User Documentation: https://docs.aerogear.org
Community Documentation: https://aerogear.org
Issue tracker: https://issues.jboss.org/browse/AEROGEAR
Mailing lists: https://groups.google.com/forum/#!forum/aerogear

Getting started

Add the following dependencies to your pom.xml file:

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

Usage

Create a JavaSender:

PushSender defaultPushSender = DefaultPushSender
    .withRootServerURL("<pushServerURL e.g http(s)//host:port/context>")
    .pushApplicationId("<pushApplicationId e.g. 1234456-234320>")
    .masterSecret("<masterSecret e.g. 1234456-234320>")
    .build();

You can also use an external config file:

pushConfig.json

{
    "serverUrl": "<pushServerURL e.g http(s)//host:port/context>",
    "pushApplicationId": "<pushApplicationId e.g. 1234456-234320>",
    "masterSecret": "<masterSecret e.g. 1234456-234320>"
}

And then :

PushSender defaultPushSender = DefaultPushSender
    .withConfig("pushConfig.json")
    .build();

To connect via proxy:

PushSender defaultPushSender = DefaultPushSender
    .withConfig("pushConfig.json")
    .proxy("proxy.example.com", 8080)
    .proxyUser("proxyuser")
    .proxyPassword("password")
    .proxyType(Proxy.Type.HTTP)
    .build();

To use a custom TrustStore:

PushSender defaultPushSender = DefaultPushSender
    .withConfig("pushConfig.json")
    .customTrustStore("setup/aerogear.truststore", "jks", "aerogear")
    .build();

Send a message

Construct a UnifiedMessage using the Builder :

UnifiedMessage unifiedMessage = UnifiedMessage.withCriteria()
    .aliases("john", "maria")
    .message()
        .alert("Hello from Java Sender API!")
        .sound("default")
        // iOS specific
        .badge("1")
        // optional specific to your app
        .userData("some_key", "some_value")
        // optional cordova Android specific attribute (default is appName)
        .userData("title", "Cool Title") 
    .build();

Create a callback

MessageResponseCallback callback = new MessageResponseCallback() {
    @Override
    public void onComplete() {
        //do cool stuff
    }
};

Send the message

defaultPushSender.send(unifiedMessage, callback); 

You can also omit the callback

defaultPushSender.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:
...
</extensions>

<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

License

See LICENSE file

Questions?

Join our user mailing list for any questions or help! We really hope you enjoy app development with AeroGear.

Found a bug?

If you found a bug please create a ticket for us on Jira with some steps to reproduce it.

aerogear-unifiedpush-java-client's People

Contributors

cvasilak avatar danbev avatar danielpassos avatar edewit avatar keithdmoore avatar kpiwko avatar lfryc avatar lholmquist avatar matzew avatar qmx avatar sebastienblanc avatar secondsun avatar tolis-e avatar vevusio avatar vibe13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.