com.notnoop.apns.internal
Class ApnsServiceImpl

java.lang.Object
  extended by com.notnoop.apns.internal.ApnsServiceImpl
All Implemented Interfaces:
ApnsService

public class ApnsServiceImpl
extends Object


Constructor Summary
ApnsServiceImpl(ApnsConnection connection, ApnsFeedbackConnection feedback)
           
 
Method Summary
 Map<String,Date> getInactiveDevices()
          Returns the list of devices that reported failed-delivery attempts to the Apple Feedback services.
 void push(ApnsNotification msg)
          Sends the provided notification message to the desired destination.
 EnhancedApnsNotification push(byte[] deviceToken, byte[] payload)
          Sends a push notification with the provided payload to the iPhone of deviceToken.
 EnhancedApnsNotification push(byte[] deviceToken, byte[] payload, int expiry)
           
 Collection<EnhancedApnsNotification> push(Collection<byte[]> deviceTokens, byte[] payload)
          Sends a bulk push notification with the provided payload to iPhone of deviceTokens set.
 Collection<EnhancedApnsNotification> push(Collection<byte[]> deviceTokens, byte[] payload, int expiry)
           
 Collection<EnhancedApnsNotification> push(Collection<String> deviceTokens, String payload)
          Sends a bulk push notification with the provided payload to iPhone of deviceTokens set.
 Collection<EnhancedApnsNotification> push(Collection<String> deviceTokens, String payload, Date expiry)
           
 EnhancedApnsNotification push(String deviceToken, String payload)
          Sends a push notification with the provided payload to the iPhone of deviceToken.
 EnhancedApnsNotification 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApnsServiceImpl

public ApnsServiceImpl(ApnsConnection connection,
                       ApnsFeedbackConnection feedback)
Method Detail

push

public void push(ApnsNotification msg)
          throws NetworkIOException
Description copied from interface: ApnsService
Sends the provided notification message to the desired destination.

Specified by:
push in interface ApnsService
Throws:
NetworkIOException - if a network error occured while attempting to send the message

start

public void start()
Description copied from interface: ApnsService
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.


stop

public void stop()
Description copied from interface: ApnsService
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.


testConnection

public void testConnection()
Description copied from interface: ApnsService
Test that the service is setup properly and the Apple servers are reachable.


push

public EnhancedApnsNotification push(String deviceToken,
                                     String payload)
                              throws NetworkIOException
Description copied from interface: ApnsService
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.

Specified by:
push in interface ApnsService
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

public EnhancedApnsNotification push(String deviceToken,
                                     String payload,
                                     Date expiry)
                              throws NetworkIOException
Specified by:
push in interface ApnsService
Throws:
NetworkIOException

push

public EnhancedApnsNotification push(byte[] deviceToken,
                                     byte[] payload)
                              throws NetworkIOException
Description copied from interface: ApnsService
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.

Specified by:
push in interface ApnsService
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

public EnhancedApnsNotification push(byte[] deviceToken,
                                     byte[] payload,
                                     int expiry)
                              throws NetworkIOException
Specified by:
push in interface ApnsService
Throws:
NetworkIOException

push

public Collection<EnhancedApnsNotification> push(Collection<String> deviceTokens,
                                                 String payload)
                                          throws NetworkIOException
Description copied from interface: ApnsService
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.

Specified by:
push in interface ApnsService
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

public Collection<EnhancedApnsNotification> push(Collection<String> deviceTokens,
                                                 String payload,
                                                 Date expiry)
                                          throws NetworkIOException
Specified by:
push in interface ApnsService
Throws:
NetworkIOException

push

public Collection<EnhancedApnsNotification> push(Collection<byte[]> deviceTokens,
                                                 byte[] payload)
                                          throws NetworkIOException
Description copied from interface: ApnsService
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.

Specified by:
push in interface ApnsService
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

public Collection<EnhancedApnsNotification> push(Collection<byte[]> deviceTokens,
                                                 byte[] payload,
                                                 int expiry)
                                          throws NetworkIOException
Specified by:
push in interface ApnsService
Throws:
NetworkIOException

getInactiveDevices

public Map<String,Date> getInactiveDevices()
                                    throws NetworkIOException
Description copied from interface: ApnsService
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.

Specified by:
getInactiveDevices in interface ApnsService
Throws:
NetworkIOException - if a network error occurred while retrieving invalid device connection


Copyright © 2013. All Rights Reserved.