Skip to content
Java client library for Urban Airship Connect
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Urban Airship Connect Client Library

This is the official supported Java library for Urban Airship Connect.


Manual installation

Clone the repository, and use

    mvn package

to build the jar. Add the jar, located at a path similar to:


If you would like a copy of the javadocs, use

    mvn javadoc:javadoc

Maven Installation

Add the following to your pom.xml

<!-- Urban Airship Library Dependency-->
        <!-- Replace VERSION with the version you want to use -->


The client library provides all the components you need to consume a Connect direct stream.

Note that Connect requests with this client may experience SSL handshake failures unless using the Java Cryptography Extension (JCE) Unlimited Strength package cipher suite.

If you encounter a generic connection failure java.lang.RuntimeException, the max strength encryption policy might be the culprit, and you should ensure this JCE Unlimited Strength package is installed on your system.

You can find the JCE Unlimited Strength package at the following locations. Choose the one that corresponds to your JRE version.

These files are not required for JRE 9 or for JRE 8u151 or newer.


An example of consuming from the client and then disconnecting may look something like:

        Creds creds = Creds.newBuilder()
        // can also set filter, subset, or offset specifications
        StreamQueryDescriptor descriptor = StreamQueryDescriptor.newBuilder()
        final Stream stream = new Stream(descriptor, Optional.<StartPosition>absent());
        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
        Runnable stopConsuming = new Runnable() {
            public void run() {
                try {
                } catch (Exception e) {
                } finally {
        scheduledExecutorService.schedule(stopConsuming, 60, TimeUnit.SECONDS);

            String event =;
            System.out.println("Event: " + event);


Begin by creating a StreamQueryDescriptor instance. This will contain the app credentials, any request filters, a starting offset, offset update preference, and any subset options.

If offset updates are enabled, then regardless of other filters provided the stream may contain events with type OFFSET_UPDATE. These don't correspond to any activity in Urban Airship's systems and requests for the same stream position will not return the same OFFSET_UPDATE events. The offsets on them will be the same as some other event in the stream. They serve to allow clients to update stored offsets in the case of low traffic or filters removing large portions of the stream.

First, store the app credentials (app key and auth token) in a Creds object:

        Creds creds = Creds.newBuilder()

Next, you will want to build any request filters or subset. See the request documentation for the thorough description on filter and subset options and combinations. A basic example might be:

         // individual device filters
        DeviceFilter device1 = new DeviceFilter(DeviceFilterType.ANDROID_CHANNEL, "152d00c3-c49c-4172-88ce-539c511cf346");
        DeviceFilter device2 = new DeviceFilter(DeviceFilterType.IOS_CHANNEL, "67fa2bad-9e83-4259-b925-bc08c184f72e");
        DeviceFilter device3 = new DeviceFilter(DeviceFilterType.NAMED_USER_ID, "cool_user");
         // notification filter by group ID
        NotificationFilter notification = new NotificationFilter(NotificationFilter.Type.GROUP_ID, "58179035-dd1f-4b04-b023-5035c6335786");
         Filter filter = Filter.newBuilder()
             .addDevices(device1, device2, device3)
             .addDeviceTypes(DeviceType.ANDROID, DeviceType.IOS)
         Subset subset = Subset.createSampleSubset(0.3);
        StreamQueryDescriptor descriptor = StreamQueryDescriptor.newBuilder()
You can’t perform that action at this time.