public class SyncOkHttpApnsClient extends java.lang.Object implements ApnsClient
| Modifier and Type | Field and Description |
|---|---|
protected okhttp3.OkHttpClient |
client |
| Constructor and Description |
|---|
SyncOkHttpApnsClient(java.io.InputStream certificate,
java.lang.String password,
boolean production,
java.lang.String defaultTopic,
okhttp3.ConnectionPool connectionPool)
Creates a new client and automatically loads the key store
with the push certificate read from the input stream.
|
SyncOkHttpApnsClient(java.io.InputStream certificate,
java.lang.String password,
boolean production,
java.lang.String defaultTopic,
okhttp3.OkHttpClient.Builder builder)
Creates a new client and automatically loads the key store
with the push certificate read from the input stream.
|
SyncOkHttpApnsClient(java.io.InputStream certificate,
java.lang.String password,
boolean production,
java.lang.String defaultTopic,
okhttp3.OkHttpClient.Builder builder,
int connectionPort)
Creates a new client and automatically loads the key store
with the push certificate read from the input stream.
|
SyncOkHttpApnsClient(java.lang.String apnsAuthKey,
java.lang.String teamID,
java.lang.String keyID,
boolean production,
java.lang.String defaultTopic,
okhttp3.ConnectionPool connectionPool)
Creates a new client which uses token authentication API.
|
SyncOkHttpApnsClient(java.lang.String apnsAuthKey,
java.lang.String teamID,
java.lang.String keyID,
boolean production,
java.lang.String defaultTopic,
okhttp3.OkHttpClient.Builder clientBuilder)
Creates a new client which uses token authentication API.
|
SyncOkHttpApnsClient(java.lang.String apnsAuthKey,
java.lang.String teamID,
java.lang.String keyID,
boolean production,
java.lang.String defaultTopic,
okhttp3.OkHttpClient.Builder clientBuilder,
int connectionPort)
Creates a new client which uses token authentication API.
|
| Modifier and Type | Method and Description |
|---|---|
protected okhttp3.Request |
buildRequest(Notification notification) |
okhttp3.OkHttpClient |
getHttpClient()
Returns the underlying OkHttpClient instance.
|
boolean |
isSynchronous()
Checks whether the client supports synchronous operations.
|
protected NotificationResponse |
parseResponse(okhttp3.Response response) |
NotificationResponse |
push(Notification notification)
Sends a notification synchronously to the Apple Push Notification Service.
|
void |
push(Notification notification,
NotificationResponseListener listener)
Sends a notification asynchronously to the Apple Push Notification Service.
|
public SyncOkHttpApnsClient(java.lang.String apnsAuthKey,
java.lang.String teamID,
java.lang.String keyID,
boolean production,
java.lang.String defaultTopic,
okhttp3.OkHttpClient.Builder clientBuilder)
apnsAuthKey - The private key - exclude -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY-----teamID - The team IDkeyID - The key ID (retrieved from the file name)production - Whether to use the production endpoint or the sandbox endpointdefaultTopic - A default topic (can be changed per message)clientBuilder - An OkHttp client builder, possibly pre-initialized, to build the actual clientpublic SyncOkHttpApnsClient(java.lang.String apnsAuthKey,
java.lang.String teamID,
java.lang.String keyID,
boolean production,
java.lang.String defaultTopic,
okhttp3.OkHttpClient.Builder clientBuilder,
int connectionPort)
apnsAuthKey - The private key - exclude -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY-----teamID - The team IDkeyID - The key ID (retrieved from the file name)production - Whether to use the production endpoint or the sandbox endpointdefaultTopic - A default topic (can be changed per message)clientBuilder - An OkHttp client builder, possibly pre-initialized, to build the actual clientconnectionPort - The port to establish a connection with APNs. Either 443 or 2197public SyncOkHttpApnsClient(java.lang.String apnsAuthKey,
java.lang.String teamID,
java.lang.String keyID,
boolean production,
java.lang.String defaultTopic,
okhttp3.ConnectionPool connectionPool)
apnsAuthKey - The private key - exclude -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY-----teamID - The team IDkeyID - The key ID (retrieved from the file name)production - Whether to use the production endpoint or the sandbox endpointdefaultTopic - A default topic (can be changed per message)connectionPool - A connection pool to use. If null, a new one will be generatedpublic SyncOkHttpApnsClient(java.io.InputStream certificate,
java.lang.String password,
boolean production,
java.lang.String defaultTopic,
okhttp3.OkHttpClient.Builder builder)
throws java.security.cert.CertificateException,
java.security.NoSuchAlgorithmException,
java.security.KeyStoreException,
java.io.IOException,
java.security.UnrecoverableKeyException,
java.security.KeyManagementException
certificate - The client certificate to be usedpassword - The password (if required, else null)production - Whether to use the production endpoint or the sandbox endpointdefaultTopic - A default topic (can be changed per message)builder - An OkHttp client builder, possibly pre-initialized, to build the actual clientjava.security.UnrecoverableKeyException - If the key cannot be recoveredjava.security.KeyManagementException - if the key failed to be loadedjava.security.cert.CertificateException - if any of the certificates in the keystore could not be loadedjava.security.NoSuchAlgorithmException - if the algorithm used to check the integrity of the keystore cannot be foundjava.io.IOException - if there is an I/O or format problem with the keystore data,
if a password is required but not given, or if the given password was incorrectjava.security.KeyStoreException - if no Provider supports a KeyStoreSpi implementation for the specified typepublic SyncOkHttpApnsClient(java.io.InputStream certificate,
java.lang.String password,
boolean production,
java.lang.String defaultTopic,
okhttp3.OkHttpClient.Builder builder,
int connectionPort)
throws java.security.cert.CertificateException,
java.security.NoSuchAlgorithmException,
java.security.KeyStoreException,
java.io.IOException,
java.security.UnrecoverableKeyException,
java.security.KeyManagementException
certificate - The client certificate to be usedpassword - The password (if required, else null)production - Whether to use the production endpoint or the sandbox endpointdefaultTopic - A default topic (can be changed per message)builder - An OkHttp client builder, possibly pre-initialized, to build the actual clientconnectionPort - The port to establish a connection with APNs. Either 443 or 2197java.security.UnrecoverableKeyException - If the key cannot be recoveredjava.security.KeyManagementException - if the key failed to be loadedjava.security.cert.CertificateException - if any of the certificates in the keystore could not be loadedjava.security.NoSuchAlgorithmException - if the algorithm used to check the integrity of the keystore cannot be foundjava.io.IOException - if there is an I/O or format problem with the keystore data,
if a password is required but not given, or if the given password was incorrectjava.security.KeyStoreException - if no Provider supports a KeyStoreSpi implementation for the specified typepublic SyncOkHttpApnsClient(java.io.InputStream certificate,
java.lang.String password,
boolean production,
java.lang.String defaultTopic,
okhttp3.ConnectionPool connectionPool)
throws java.security.cert.CertificateException,
java.security.NoSuchAlgorithmException,
java.security.KeyStoreException,
java.io.IOException,
java.security.UnrecoverableKeyException,
java.security.KeyManagementException
certificate - The client certificate to be usedpassword - The password (if required, else null)production - Whether to use the production endpoint or the sandbox endpointdefaultTopic - A default topic (can be changed per message)connectionPool - A connection pool to use. If null, a new one will be generatedjava.security.UnrecoverableKeyException - If the key cannot be recoveredjava.security.KeyManagementException - if the key failed to be loadedjava.security.cert.CertificateException - if any of the certificates in the keystore could not be loadedjava.security.NoSuchAlgorithmException - if the algorithm used to check the integrity of the keystore cannot be foundjava.io.IOException - if there is an I/O or format problem with the keystore data,
if a password is required but not given, or if the given password was incorrectjava.security.KeyStoreException - if no Provider supports a KeyStoreSpi implementation for the specified typepublic boolean isSynchronous()
ApnsClientThis is specified when building the client using
isSynchronous in interface ApnsClientpublic void push(Notification notification, NotificationResponseListener listener)
ApnsClientpush in interface ApnsClientnotification - The notification built using
Notification.Builderlistener - The listener to be called after the request is completeprotected final okhttp3.Request buildRequest(Notification notification)
public NotificationResponse push(Notification notification)
ApnsClientpush in interface ApnsClientnotification - The notification built using
Notification.Builderpublic okhttp3.OkHttpClient getHttpClient()
ApnsClientgetHttpClient in interface ApnsClientprotected NotificationResponse parseResponse(okhttp3.Response response) throws java.io.IOException
java.io.IOExceptionCopyright © 2020. All Rights Reserved.