AeroGear Java Client Library

Open Source Libraries for Mobile Connectivity

License

License

Categories

Categories

Java Languages JBoss Container Application Servers CLI User Interface
GroupId

GroupId

org.jboss.aerogear
ArtifactId

ArtifactId

unifiedpush-java-client
Last Version

Last Version

1.1.0.Final
Release Date

Release Date

Type

Type

jar
Description

Description

AeroGear Java Client Library
Open Source Libraries for Mobile Connectivity
Project Organization

Project Organization

JBoss by Red Hat
Source Code Management

Source Code Management

https://github.com/aerogear/aerogear-unifiedpush-java-client

Download unifiedpush-java-client

How to add to project

<!-- https://jarcasting.com/artifacts/org.jboss.aerogear/unifiedpush-java-client/ -->
<dependency>
    <groupId>org.jboss.aerogear</groupId>
    <artifactId>unifiedpush-java-client</artifactId>
    <version>1.1.0.Final</version>
</dependency>
// https://jarcasting.com/artifacts/org.jboss.aerogear/unifiedpush-java-client/
implementation 'org.jboss.aerogear:unifiedpush-java-client:1.1.0.Final'
// https://jarcasting.com/artifacts/org.jboss.aerogear/unifiedpush-java-client/
implementation ("org.jboss.aerogear:unifiedpush-java-client:1.1.0.Final")
'org.jboss.aerogear:unifiedpush-java-client:jar:1.1.0.Final'
<dependency org="org.jboss.aerogear" name="unifiedpush-java-client" rev="1.1.0.Final">
  <artifact name="unifiedpush-java-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.jboss.aerogear', module='unifiedpush-java-client', version='1.1.0.Final')
)
libraryDependencies += "org.jboss.aerogear" % "unifiedpush-java-client" % "1.1.0.Final"
[org.jboss.aerogear/unifiedpush-java-client "1.1.0.Final"]

Dependencies

compile (4)

Group / Artifact Type Version
net.iharder : base64 jar
org.jboss.aerogear.unifiedpush : unifiedpush-push-model jar 1.1.0.Final
com.fasterxml.jackson.core : jackson-databind jar
com.google.code.gson : gson jar 2.3

test (3)

Group / Artifact Type Version
junit : junit jar
org.powermock : powermock-module-junit4 jar
org.powermock : powermock-api-mockito jar

Project Modules

There are no modules declared in this project.

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.

org.jboss.aerogear

AeroGear

Modern App Dev begins here - RealTime GraphQL and Push

Versions

Version
1.1.0.Final
1.1.0-beta.1
1.1.0-alpha.2
1.1.0-alpha.1
1.0.0
0.9.0
0.8.0
0.7.0
0.6.0
0.5.0
0.4.0