public class PushNotifications extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static String |
accessToken |
protected static long |
apiKeyExpireyTime |
protected static String |
apiKeyIdIs |
static String |
FRANKFURT_REGION |
static String |
JP_TOK |
static Logger |
logger |
static String |
overrideServerHost
Overrides default server host with the provided host.
|
protected static String |
pushMessageEndpointURL |
protected static String |
secret |
static String |
SYDNEY_REGION |
static String |
UK_REGION |
static String |
US_EAST_REGION |
static String |
US_SOUTH_REGION |
| Constructor and Description |
|---|
PushNotifications() |
| Modifier and Type | Method and Description |
|---|---|
protected static org.apache.http.client.methods.HttpPost |
createBulkPushPostRequest(List<org.json.JSONObject> messageJson) |
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() |
static org.apache.http.client.methods.CloseableHttpResponse |
getAuthToken() |
protected static String |
getEnvironmentVariable(String name) |
protected static String |
getPushApiKeyFromVCAP() |
protected static String |
getPushSecretFromVCAP() |
static void |
init(String ibmCloudRegion)
If your application server is running on IBM Cloud, and your push
notification service is bound to your application, you can use this
method for initialization which will get the credentials from IBM Cloud's
environment variables.
|
static void |
init(String tenantId,
String pushSecret,
String ibmCloudRegion)
Specify the credentials and IBM Cloud region for your push notification
service.
|
static void |
initWithApiKey(String tenantId,
String apiKeyId,
String ibmCloudRegionn) |
static void |
send(Notification notification,
PushNotificationsResponseListener listener)
Send the given push notification, as configured, to devices using the
Push Notification service.
|
static void |
sendBulk(Notification[] notifications,
PushNotificationsResponseListener listener) |
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 String FRANKFURT_REGION
public static final String US_EAST_REGION
public static final String JP_TOK
public static final Logger logger
protected static String secret
protected static String apiKeyIdIs
protected static long apiKeyExpireyTime
protected static String accessToken
protected static String pushMessageEndpointURL
public static String overrideServerHost
overrideServerHost can be used for dedicated service and
overrides default host with dedicated service host.public static void init(String tenantId, String pushSecret, String ibmCloudRegion)
tenantId - The tenant ID for the IBM Cloud application that the Push
Notifications service is bound to.pushSecret - The credential required for Push Notifications service
authorization.ibmCloudRegion - The IBM Cloud region where the Push Notifications service is
hosted. For example, US_SOUTH_REGION.public static void init(String ibmCloudRegion)
ibmCloudRegion - The IBM Cloud region where the Push Notifications service is
hosted. For example, US_SOUTH_REGION.IllegalArgumentException - If either the push application ID or the secret is not found
in the environment variables.public static void initWithApiKey(String tenantId, String apiKeyId, String ibmCloudRegionn)
public static org.apache.http.client.methods.CloseableHttpResponse getAuthToken()
protected static String getApplicationIdFromVCAP()
protected static String getPushSecretFromVCAP()
protected static String getPushApiKeyFromVCAP()
public static void send(Notification notification, PushNotificationsResponseListener listener)
notification - The push notification to be sent.listener - Optional PushNotificationsResponseListener to listen to the
result of this operation.public static void sendBulk(Notification[] notifications, PushNotificationsResponseListener listener)
protected static org.apache.http.client.methods.HttpPost createPushPostRequest(org.json.JSONObject notification)
protected static org.apache.http.client.methods.HttpPost createBulkPushPostRequest(List<org.json.JSONObject> messageJson)
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 © 2020. All rights reserved.