unified-push-java-client

Open Source Libraries for Mobile Connectivity

License

License

Categories

Categories

Java Languages JBoss Container Application Servers CLI User Interface
GroupId

GroupId

org.jboss.aerogear.unifiedpush
ArtifactId

ArtifactId

unified-push-java-client
Last Version

Last Version

0.3.0
Release Date

Release Date

Type

Type

jar
Description

Description

unified-push-java-client
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-unified-push-java-client

Download unified-push-java-client

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
net.iharder : base64 jar 2.3.8

provided (1)

Group / Artifact Type Version
org.jboss.resteasy : resteasy-jackson-provider jar 2.3.2.Final

test (2)

Group / Artifact Type Version
junit : junit jar 4.8
org.mockito : mockito-core jar 1.9.0

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.unifiedpush

AeroGear

Modern App Dev begins here - RealTime GraphQL and Push

Versions

Version
0.3.0
0.2.2
0.2.1
0.2.0