com.notnoop.apns
Interface ApnsService


public interface ApnsService

Represents the connection and interface to the Apple APNS servers. The service is created by ApnsServiceBuilder like:

   ApnsService = APNS.newService()
                  .withCert("/path/to/certificate.p12", "MyCertPassword")
                  .withSandboxDestination()
                  .build()
 


Method Summary
 Map<String,Date> getInactiveDevices()
          Returns the list of devices that reported failed-delivery attempts to the Apple Feedback services.
 void push(ApnsNotification message)
          Sends the provided notification message to the desired destination.
 void push(byte[] deviceToken, byte[] payload)
          Sends a push notification with the provided payload to the iPhone of deviceToken.
 void push(byte[] deviceToken, byte[] payload, int expiry)
           
 void push(Collection<byte[]> deviceTokens, byte[] payload)
          Sends a bulk push notification with the provided payload to iPhone of deviceTokens set.
 void push(Collection<byte[]> deviceTokens, byte[] payload, int expiry)
           
 void push(Collection<String> deviceTokens, String payload)
          Sends a bulk push notification with the provided payload to iPhone of deviceTokens set.
 void push(Collection<String> deviceTokens, String payload, Date expiry)
           
 void push(String deviceToken, String payload)
          Sends a push notification with the provided payload to the iPhone of deviceToken.
 void push(String deviceToken, String payload, Date expiry)
           
 void start()
          Starts the service.
 void stop()
          Stops the service and frees any allocated resources it created for this service.
 void testConnection()
          Test that the service is setup properly and the Apple servers are reachable.
 

Method Detail

push

void push(String deviceToken,
          String payload)
          throws NetworkIOException
Sends a push notification with the provided payload to the iPhone of deviceToken. The payload needs to be a valid JSON object, otherwise it may fail silently. It is recommended to use PayloadBuilder to create one.

Parameters:
deviceToken - the destination iPhone device token
payload - The payload message
Throws:
NetworkIOException - if a network error occured while attempting to send the message

push

void push(String deviceToken,
          String payload,
          Date expiry)
          throws NetworkIOException
Throws:
NetworkIOException

push

void push(byte[] deviceToken,
          byte[] payload)
          throws NetworkIOException
Sends a push notification with the provided payload to the iPhone of deviceToken. The payload needs to be a valid JSON object, otherwise it may fail silently. It is recommended to use PayloadBuilder to create one.

Parameters:
deviceToken - the destination iPhone device token
payload - The payload message
Throws:
NetworkIOException - if a network error occurred while attempting to send the message

push

void push(byte[] deviceToken,
          byte[] payload,
          int expiry)
          throws NetworkIOException
Throws:
NetworkIOException

push

void push(Collection<String> deviceTokens,
          String payload)
          throws NetworkIOException
Sends a bulk push notification with the provided payload to iPhone of deviceTokens set. The payload needs to be a valid JSON object, otherwise it may fail silently. It is recommended to use PayloadBuilder to create one.

Parameters:
deviceTokens - the destination iPhone device tokens
payload - The payload message
Throws:
NetworkIOException - if a network error occurred while attempting to send the message

push

void push(Collection<String> deviceTokens,
          String payload,
          Date expiry)
          throws NetworkIOException
Throws:
NetworkIOException

push

void push(Collection<byte[]> deviceTokens,
          byte[] payload)
          throws NetworkIOException
Sends a bulk push notification with the provided payload to iPhone of deviceTokens set. The payload needs to be a valid JSON object, otherwise it may fail silently. It is recommended to use PayloadBuilder to create one.

Parameters:
deviceTokens - the destination iPhone device tokens
payload - The payload message
Throws:
NetworkIOException - if a network error occurred while attempting to send the message

push

void push(Collection<byte[]> deviceTokens,
          byte[] payload,
          int expiry)
          throws NetworkIOException
Throws:
NetworkIOException

push

void push(ApnsNotification message)
          throws NetworkIOException
Sends the provided notification message to the desired destination.

Throws:
NetworkIOException - if a network error occured while attempting to send the message

start

void start()
Starts the service. The underlying implementation may prepare its connections or datastructures to be able to send the messages. This method is a blocking call, even if the service represents a Non-blocking push service. Once the service is returned, it is ready to accept push requests.

Throws:
NetworkIOException - if a network error occurred while starting the service

stop

void stop()
Stops the service and frees any allocated resources it created for this service. The underlying implementation should close all connections it created, and possibly stop any threads as well.


getInactiveDevices

Map<String,Date> getInactiveDevices()
                                    throws NetworkIOException
Returns the list of devices that reported failed-delivery attempts to the Apple Feedback services. The result is map, mapping the device tokens as Hex Strings mapped to the timestamp when APNs determined that the application no longer exists on the device.

Throws:
NetworkIOException - if a network error occurred while retrieving invalid device connection

testConnection

void testConnection()
                    throws NetworkIOException
Test that the service is setup properly and the Apple servers are reachable.

Throws:
NetworkIOException - if the Apple servers aren't reachable or the service cannot send notifications for now


Copyright © 2011. All Rights Reserved.