use of com.notnoop.apns.EnhancedApnsNotification in project camel by apache.
the class ApnsProducerTest method testProducer.
@Test(timeout = 5000)
public void testProducer() throws Exception {
String message = "Hello World";
String messagePayload = APNS.newPayload().alertBody(message).build();
EnhancedApnsNotification apnsNotification = new EnhancedApnsNotification(1, EnhancedApnsNotification.MAXIMUM_EXPIRY, FAKE_TOKEN, messagePayload);
server.stopAt(apnsNotification.length());
template.sendBody("direct:test", message);
server.getMessages().acquire();
assertArrayEquals(apnsNotification.marshall(), server.getReceived().toByteArray());
}
use of com.notnoop.apns.EnhancedApnsNotification in project camel by apache.
the class ApnsProducerTest method testProducerWithApnsNotification.
@Test(timeout = 5000)
public void testProducerWithApnsNotification() throws InterruptedException {
String message = "Hello World";
String messagePayload = APNS.newPayload().alertBody(message).build();
final EnhancedApnsNotification apnsNotification = new EnhancedApnsNotification(14, EnhancedApnsNotification.MAXIMUM_EXPIRY, FAKE_TOKEN, messagePayload);
server.stopAt(apnsNotification.length());
template.sendBody("direct:testWithApnsNotification", apnsNotification);
server.getMessages().acquire();
assertArrayEquals(apnsNotification.marshall(), server.getReceived().toByteArray());
}
use of com.notnoop.apns.EnhancedApnsNotification in project java-apns by notnoop.
the class AbstractApnsService method push.
public EnhancedApnsNotification push(String deviceToken, String payload, Date expiry) throws NetworkIOException {
EnhancedApnsNotification notification = new EnhancedApnsNotification(c.incrementAndGet(), (int) (expiry.getTime() / 1000), deviceToken, payload);
push(notification);
return notification;
}
use of com.notnoop.apns.EnhancedApnsNotification in project java-apns by notnoop.
the class AbstractApnsService method push.
public Collection<EnhancedApnsNotification> push(Collection<String> deviceTokens, String payload, Date expiry) throws NetworkIOException {
byte[] messageBytes = Utilities.toUTF8Bytes(payload);
List<EnhancedApnsNotification> notifications = new ArrayList<EnhancedApnsNotification>(deviceTokens.size());
for (String deviceToken : deviceTokens) {
byte[] dtBytes = Utilities.decodeHex(deviceToken);
EnhancedApnsNotification notification = new EnhancedApnsNotification(c.incrementAndGet(), (int) (expiry.getTime() / 1000), dtBytes, messageBytes);
notifications.add(notification);
push(notification);
}
return notifications;
}
use of com.notnoop.apns.EnhancedApnsNotification in project java-apns by notnoop.
the class AbstractApnsService method push.
public Collection<EnhancedApnsNotification> push(Collection<byte[]> deviceTokens, byte[] payload, int expiry) throws NetworkIOException {
List<EnhancedApnsNotification> notifications = new ArrayList<EnhancedApnsNotification>(deviceTokens.size());
for (byte[] deviceToken : deviceTokens) {
EnhancedApnsNotification notification = new EnhancedApnsNotification(c.incrementAndGet(), expiry, deviceToken, payload);
notifications.add(notification);
push(notification);
}
return notifications;
}
Aggregations