2

I want to use Urban airship to deliver Push notification to Android. I can send Push notification from Urban Airship site but i don't know how can i send messages in Java application using urban Airship web service.

i don't want to go to their site and send message to any Android device i just wanted my personal website (developed in Java EE) to use their service and send messages to android devices.

plz share any code or toturial
Thanks in advance

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
waseemwk
  • 1,499
  • 3
  • 15
  • 44

3 Answers3

4

This project in bitbucket encapsulates the Urban Airship REST API in Java.

https://bitbucket.org/sullis/urbanairship-java

The project has external dependencies on following libraries:

  • commons codec
  • commons logging
  • google gson
  • apache http client
  • apache http core

Once downloaded and compiled, you can send the push notification with following code:

public static void sendNotification() {
        Push push = new Push();
        push.setAliases(Arrays.asList("39901"));

        // For Android
        Android android = new Android();
        android.setAlert("hi there");
        push.setAndroid(android);

        // For iOS
        // APS aps = new APS();
        // aps.setBadge(1);
        // aps.setAlert("hi there");
        // aps.setSound("default");
        // aps.setData("additinoal data");
        // push.setAps(aps);

        UrbanAirshipClient uac = new UrbanAirshipClient("app key",
                "master app key");
        uac.sendPushNotifications(push);
    }
dhaval
  • 7,611
  • 3
  • 29
  • 38
  • Thanks @dhaval for your response.. can i use Urban Airship without using third party library – waseemwk Mar 08 '12 at 18:57
  • actually listed libraries are required to compile the api source code so you will not be able to use it otherwise. Second option is to write your own java api but you still will be end up using some external libraries to avoid writing a lot of code. – dhaval Mar 08 '12 at 19:00
0

urbanairship4j (available on Google Code) uses Google HTTP Java Client so works perfectly on any Java environment (inc. AppEngine, Android, etc).

dleshem
  • 43
  • 5
0

Try using the official Urban Airship Java API - This should help you get started...

Alon Rosenfeld
  • 1,392
  • 13
  • 13