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

https://github.com/adorsys/pushit

this library is a normalized wrapper over GCM and APNs
https://github.com/adorsys/pushit

Last synced: about 1 month ago
JSON representation

this library is a normalized wrapper over GCM and APNs

Awesome Lists containing this project

README

          

# pushit

## Usage

Add the BOM to your maven dependencyManagement:
```xml



de.adorsys.pushit
bom
0.2.0
pom
import



```
This defines the versions for all the pushit artefact as well as the apns and gcm implementations.
You can now add the dependencies:
```xml

de.adorsys.pushit
pushit



com.notnoop.apns
apns



com.google.gcm
gcm-server

```

Example to send a simple message to an iOS and Android device:
```java
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import de.adorsys.pushit.apns.ApnsSender;
import de.adorsys.pushit.gcm.GcmSender;

public class TestCommonMessageMain {
private static final Config conf = ConfigFactory.load();
private static final String keyFilename = conf.getString("apns.keyFile");
private static final String keyPassphrase = conf.getString("apns.keyPassphrase");
private static final String deviceToken = conf.getString("apns.deviceToken");
private static final String apiKey = conf.getString("gcm.apiKey");
private static final String registrationId = conf.getString("gcm.registrationId");

public static void main(String[] args) {
ApnsSender apnsSender = ApnsSender.create(keyFilename, keyPassphrase);
GcmSender gcmSender = GcmSender.create(apiKey);
Dispatcher dispatcher = new Dispatcher.Builder().apnsSender(apnsSender).gcmSender(gcmSender).build();
Message.TextMessage message = new Message.TextMessage("Hi from pushit");
Receiver receiver = new Receiver.Builder().addApnsToken(deviceToken).addGcmToken(registrationId).build();
dispatcher.send(message, receiver);
}
}
```