Reputation: 1509
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
Upvotes: 2
Views: 4146
Reputation: 1469
Try using the official Urban Airship Java API - This should help you get started...
Upvotes: 0
Reputation: 43
urbanairship4j (available on Google Code) uses Google HTTP Java Client so works perfectly on any Java environment (inc. AppEngine, Android, etc).
Upvotes: 0
Reputation: 7659
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:
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);
}
Upvotes: 4