Search in sources :

Example 6 with EnhancedApnsNotification

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();
        }
    }
}
Also used : EnhancedApnsNotification(com.notnoop.apns.EnhancedApnsNotification) ApnsNotification(com.notnoop.apns.ApnsNotification) EnhancedApnsNotification(com.notnoop.apns.EnhancedApnsNotification)

Example 7 with EnhancedApnsNotification

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());
}
Also used : EnhancedApnsNotification(com.notnoop.apns.EnhancedApnsNotification) Test(org.junit.Test)

Example 8 with EnhancedApnsNotification

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());
}
Also used : EnhancedApnsNotification(com.notnoop.apns.EnhancedApnsNotification) Test(org.junit.Test)

Example 9 with EnhancedApnsNotification

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;
}
Also used : EnhancedApnsNotification(com.notnoop.apns.EnhancedApnsNotification) ArrayList(java.util.ArrayList)

Example 10 with EnhancedApnsNotification

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;
}
Also used : EnhancedApnsNotification(com.notnoop.apns.EnhancedApnsNotification)

Aggregations

EnhancedApnsNotification (com.notnoop.apns.EnhancedApnsNotification)12 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)3 ApnsNotification (com.notnoop.apns.ApnsNotification)1