Skip to content

Java client library for the Urban Airship API

License

Notifications You must be signed in to change notification settings

allanfrankwork/java-library

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Urban Airship Java Client Library

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

Using the library is straightforward. Create a client, setup a request payload, handle the results.

    String appKey = "appKey";
    String appSecret = "appSecret";

    // Setup an authenticated APIClient with your application key and
    // application master secret.
    APIClient apiClient = APIClient.newBuilder()
            .setKey(appKey)
            .setSecret(appSecret)
            .build();

    // Setup a push payload to send to the API with our handy builders
    PushPayload payload = PushPayload.newBuilder()
            .setAudience(Selectors.all())
            .setNotification(Notifications.notification("UA Push"))
            .setDeviceTypes(DeviceTypeData.of(DeviceType.IOS))
            .build();
    // Try and send, handle anything that comes up
    try {
        APIClientResponse<APIPushResponse> response = apiClient.push(payload);
        logger.info("Sent a push message!");
    }
    // Non 200 responses throw an APIRequestException. Check the documentation
    // to debug your request.
    catch (APIRequestException ex){
        logger.error("Non 200 request, checking error details and taking action");
    }
    // An underlying error occurred, most likely outside of the scope of the
    // UA library, do some HTTP debugging
    catch (IOException e){
        logger.error("Broken pipe what?");
    }

Documentation

General documentation can be found here: http://docs.urbanairship.com/ Java client library documentation can be found here: http://docs.urbanairship.com/reference/libraries/java/index.html

Installation

Manual installation

Clone the repository, and use

    mvn package

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

    target/java-client-<version>.jar

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-->
    <dependency>
        <groupId>com.urbanairship</groupId>
        <artifactId>java-client</artifactId>
        <version>0.2.VERSION</version>
        <!-- Replace VERSION with the version you want to use -->
    </dependency>

Examples

There is an example project in the examples directory with code to send a push, a scheduled push, logging, and Maven integration.

Full documentation: http://docs.urbanairship.com/reference/libraries/java/index.html

About

Java client library for the Urban Airship API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 98.7%
  • Other 1.3%