|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.relayrides.pushy.apns.PushManager<T>
public class PushManager<T extends ApnsPushNotification>
A PushManager
is the main public-facing point of interaction with APNs. PushManager
s manage the
queue of outbound push notifications and manage connections to the various APNs servers.
Constructor Summary | |
---|---|
PushManager(ApnsEnvironment environment,
KeyStore keyStore,
char[] keyStorePassword)
Constructs a new PushManager that operates in the given environment with the given credentials and a
single connection to APNs. |
|
PushManager(ApnsEnvironment environment,
KeyStore keyStore,
char[] keyStorePassword,
int concurrentConnections)
Constructs a new PushManager that operates in the given environment with the given credentials and the
given number of parallel connections to APNs. |
Method Summary | |
---|---|
void |
enqueueAllNotifications(Collection<T> notifications)
Enqueues a collection of push notifications for transmission to the APNs service. |
void |
enqueuePushNotification(T notification)
Enqueues a push notification for transmission to the APNs service. |
ApnsEnvironment |
getEnvironment()
Returns the environment in which this PushManager is operating. |
List<ExpiredToken> |
getExpiredTokens()
Queries the APNs feedback service for expired tokens. |
KeyStore |
getKeyStore()
Returns the KeyStore containing the client certificate to presented to TLS-enabled APNs servers. |
char[] |
getKeyStorePassword()
Returns the key to unlock the KeyStore for this PushManager . |
void |
registerRejectedNotificationListener(RejectedNotificationListener<T> listener)
Registers a listener for notifications rejected by APNs for specific reasons. |
List<T> |
shutdown()
Disconnects from the APNs and gracefully shuts down all worker threads. |
void |
start()
Opens all connections to APNs and prepares to send push notifications. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PushManager(ApnsEnvironment environment, KeyStore keyStore, char[] keyStorePassword)
PushManager
that operates in the given environment with the given credentials and a
single connection to APNs.
environment
- the environment in which this PushManager
operateskeyStore
- A KeyStore
containing the client key to present during a TLS handshake; may be
null
if the environment does not require TLS. The KeyStore
should be loaded before being used
here.keyStorePassword
- a password to unlock the given KeyStore
; may be null
public PushManager(ApnsEnvironment environment, KeyStore keyStore, char[] keyStorePassword, int concurrentConnections)
Constructs a new PushManager
that operates in the given environment with the given credentials and the
given number of parallel connections to APNs. See
Best Practices for Managing Connections for additional information.
environment
- the environment in which this PushManager
operateskeyStore
- A KeyStore
containing the client key to present during a TLS handshake; may be
null
if the environment does not require TLS. The KeyStore
should be loaded before being used
here.keyStorePassword
- a password to unlock the given KeyStore
; may be null
concurrentConnections
- the number of parallel connections to open to APNsMethod Detail |
---|
public ApnsEnvironment getEnvironment()
PushManager
is operating.
PushManager
is operatingpublic KeyStore getKeyStore()
KeyStore
containing the client certificate to presented to TLS-enabled APNs servers.
KeyStore
containing the client certificate to presented to TLS-enabled APNs serverspublic char[] getKeyStorePassword()
KeyStore
for this PushManager
.
KeyStore
for this PushManager
public void start()
public void enqueuePushNotification(T notification)
Enqueues a push notification for transmission to the APNs service. Notifications may not be sent to APNs
immediately, and delivery is not guaranteed by APNs, but notifications rejected by APNs for specific reasons
will be passed to registered RejectedNotificationListener
s.
notification
- the notification to enqueueregisterRejectedNotificationListener(RejectedNotificationListener)
public void enqueueAllNotifications(Collection<T> notifications)
Enqueues a collection of push notifications for transmission to the APNs service. Notifications may not be
sent to APNs immediately, and delivery is not guaranteed by APNs, but notifications rejected by APNs for
specific reasons will be passed to registered RejectedNotificationListener
s.
notifications
- the notifications to enqueueregisterRejectedNotificationListener(RejectedNotificationListener)
public List<T> shutdown() throws InterruptedException
PushManager
shut down
InterruptedException
- if interrupted while waiting for worker threads to exit cleanlypublic void registerRejectedNotificationListener(RejectedNotificationListener<T> listener)
Registers a listener for notifications rejected by APNs for specific reasons. Note that listeners are stored as weak references, so callers should maintain a reference to listeners to prevent them from being garbage collected.
listener
- the listener to registerpublic List<ExpiredToken> getExpiredTokens() throws InterruptedException
Queries the APNs feedback service for expired tokens. Be warned that this is a destructive operation. According to Apple's documentation:
The feedback service’s list is cleared after you read it. Each time you connect to the feedback service, the information it returns lists only the failures that have happened since you last connected.
InterruptedException
- if interrupted while waiting for a response from the feedback service
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |