public class PushNotifications extends Object
| Modifier and Type | Field and Description |
|---|---|
static Logger |
logger |
protected static String |
pushMessageEndpointURL |
protected static String |
secret |
static String |
SYDNEY_REGION |
static String |
UK_REGION |
static String |
US_SOUTH_REGION |
| Constructor and Description |
|---|
PushNotifications() |
| Modifier and Type | Method and Description |
|---|---|
protected static org.apache.http.client.methods.HttpPost |
createPushPostRequest(org.json.JSONObject notification) |
protected static void |
executePushPostRequest(org.apache.http.client.methods.HttpPost pushPost,
org.apache.http.impl.client.CloseableHttpClient httpClient,
PushNotificationsResponseListener listener) |
protected static String |
getApplicationIdFromVCAP() |
protected static String |
getEnvironmentVariable(String name) |
protected static String |
getPushSecretFromVCAP() |
static void |
init(String bluemixRegion)
If your application server is running on Bluemix, and your push notification service is bound to your application,
you can use this method for initialization which will get the credentials from Bluemix's environment variables.
|
static void |
init(String tenantId,
String pushSecret,
String bluemixRegion)
Specify the credentials and Bluemix region for your push notification service.
|
static void |
send(org.json.JSONObject notification,
PushNotificationsResponseListener listener)
Send the given push notification, as configured, to devices using the Push Notification service.
|
protected static void |
sendResponseToListener(org.apache.http.client.methods.CloseableHttpResponse response,
PushNotificationsResponseListener listener) |
public static final String US_SOUTH_REGION
public static final String UK_REGION
public static final String SYDNEY_REGION
public static final Logger logger
protected static String secret
protected static String pushMessageEndpointURL
public static void init(String tenantId, String pushSecret, String bluemixRegion)
tenantId - the tenant ID for the Bluemix application that the Push Notifications service is bound topushSecret - the credential required for Push Notifications service authorizationbluemixRegion - the Bluemix region where the Push Notifications service is hosted, such as US_SOUTH_REGIONpublic static void init(String bluemixRegion)
bluemixRegion - the Bluemix region where the Push Notifications service is hosted, such as US_SOUTH_REGIONIllegalArgumentException - if either the push application ID or the secret are not found in the environment variablesprotected static String getApplicationIdFromVCAP()
protected static String getPushSecretFromVCAP()
public static void send(org.json.JSONObject notification,
PushNotificationsResponseListener listener)
notification - the push notification to be sentlistener - an optional PushNotificationsResponseListener to listen to the result of this operationprotected static org.apache.http.client.methods.HttpPost createPushPostRequest(org.json.JSONObject notification)
protected static void executePushPostRequest(org.apache.http.client.methods.HttpPost pushPost,
org.apache.http.impl.client.CloseableHttpClient httpClient,
PushNotificationsResponseListener listener)
protected static void sendResponseToListener(org.apache.http.client.methods.CloseableHttpResponse response,
PushNotificationsResponseListener listener)
throws IOException
IOExceptionCopyright © 2017. All rights reserved.