Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/devsu/push-sender

Java library that allows you to easily send push messages, via GCM (or FCM) and APNS.
https://github.com/devsu/push-sender

Last synced: 2 months ago
JSON representation

Java library that allows you to easily send push messages, via GCM (or FCM) and APNS.

Awesome Lists containing this project

README

        

# Push Sender [DEPRECATED]#

Push Sender is a Java library that allows sending push messages easily, based on the awesome libraries [gcm-server](https://github.com/theganyo/gcm-server) by [theganyo](https://github.com/theganyo) and [java-apns](https://github.com/notnoop/java-apns) by [notnoop](https://github.com/notnoop). Be sure to check them out! Send push messages with one line of code, forget about the rest, and focus on making your application's business logic!

## Overview ###

Using Push Sender is very simple. You can import Push Sender on your POM file using:

```

com.devsu
push-sender
1.0.3

```

## Synchronous and asynchronous push services ###

You can send your push messages synchronously and asynchronously by choosing any of the implementations of `PushService`.

```java
public class MySender {

SyncAndroidPushService syncAndroidService = new SyncAndroidPushService(GCM_API_KEY);
AsyncAndroidPushService asyncAndroidService = new SyncAndroidPushService(GCM_API_KEY, null);

SyncApplePushService syncAppleService = new SyncApplePushService(P12_FILEPATH, P12_PASSWORD, IS_PRODUCTION_ENVIRONMENT);
AsyncApplePushService asyncAppleService = new AsyncApplePushService(P12_FILEPATH, P12_PASSWORD, IS_PRODUCTION_ENVIRONMENT, null);

...

public void sendSomePushMessages() {
String title = "My Push Message Title";
String content = "Hello! This is a push message!";

syncAndroidService.sendPush(title, content, ANDROID_PUSH_TOKEN);
asyncAndroidService.sendPush(title, content, ANDROID_PUSH_TOKEN);

syncAppleService.sendPush(title, content, IOS_PUSH_TOKEN);
asyncAppleService.sendPush(title, content, IOS_PUSH_TOKEN);
}

...
}
```

## PushCallback ###

You can implement a PushCallback for any of the asynchronous services.

```java
public class MySender {

...

public void sendSomePushMessages() {
AsyncAndroidPushService asyncAndroidService = new SyncAndroidPushService(GCM_API_KEY, new PushCallback() {

@Override
public void onSingleSuccess(boolean result, String title, String message,
Map additionalFields, String token) {
System.out.println("The single message was successfully sent!");
}

@Override
public void onError(Throwable t) {
System.err.println("Oops... Something happened!");
}

@Override
public void onBulkSuccess(boolean result, String title, String message,
Map additionalFields, String[] tokens) {
System.out.println("The bulk message was successfully sent!");
}
});
}

...
}
```

## Customizing ###
+ You can customize any data sent on your push message with a `Map` that contains any key-value pair you want to send.
+ You can build your `Message.Builder` or `PayloadBuilder` objects externally and send them as push messages!
+ You can customize settings like max retries, collapse keys, production/sandbox environments, bulk size when sending simultaneous push messages on Android and more...

## Authors ##
Feel free to contact Alvaro López at [email protected]!

## License ###

Copyright 2015 Devsu Software

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.