use of com.notnoop.apns.EnhancedApnsNotification in project java-apns by notnoop.
the class ApnsConnectionImpl method testConnection.
public void testConnection() throws NetworkIOException {
ApnsConnectionImpl testConnection = null;
try {
testConnection = new ApnsConnectionImpl(factory, host, port, proxy, proxyUsername, proxyPassword, reconnectPolicy.copy(), delegate);
final ApnsNotification notification = new EnhancedApnsNotification(0, 0, new byte[] { 0 }, new byte[] { 0 });
testConnection.sendMessage(notification);
} finally {
if (testConnection != null) {
testConnection.close();
}
}
}
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 Collection<EnhancedApnsNotification> push(Collection<byte[]> deviceTokens, byte[] payload) throws NetworkIOException {
List<EnhancedApnsNotification> notifications = new ArrayList<EnhancedApnsNotification>(deviceTokens.size());
for (byte[] deviceToken : deviceTokens) {
EnhancedApnsNotification notification = new EnhancedApnsNotification(c.incrementAndGet(), EnhancedApnsNotification.MAXIMUM_EXPIRY, deviceToken, payload);
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 EnhancedApnsNotification push(byte[] deviceToken, byte[] payload) throws NetworkIOException {
EnhancedApnsNotification notification = new EnhancedApnsNotification(c.incrementAndGet(), EnhancedApnsNotification.MAXIMUM_EXPIRY, deviceToken, payload);
push(notification);
return notification;
}
Aggregations