SendNormalizedPushNotificationBatch
Sends a notification to a list of users consisting of alert content and custom data.
Service | Operation |
---|---|
pushNotification | SEND_NORMALIZED_BATCH |
Method Parameters
Parameter | Description |
---|---|
profileIds | Target user list |
alertContentJson | Body and title of alert |
customDataJson | Optional custom data |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
string[] profileIds = { "a-profile-id", "another-profile-id" };
string alertContentJson = "{\"body\":\"content of message\",\"title\":\"message title\"}";
string customDataJson = "{\"field1\":\"value1\",\"field2\":\"value2\"}";
SuccessCallback successCallback = (response, cbObject) =>
{
Debug.Log(string.Format("Success | {0}", response));
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
Debug.Log(string.Format("Failed | {0} {1} {2}", status, code, error));
};
_bc.PushNotificationService.SendNormalizedPushNotificationBatch(profileIds, alertContentJson, customDataJson, successCallback, failureCallback);
std::vector<std::string> profileIds;
profileIds.push_back("a-profile-id");
profileIds.push_back("another-profile-id");
const char *alertContentJson = "{\"body\":\"content of message\",\"title\":\"message title\"}";
const char *customDataJson = "{\"field1\":\"value1\",\"field2\":\"value2\"}";
_bc->getPushNotificationService()->sendNormalizedPushNotificationBatch(profileIds, alertContentJson, customDataJson, this);
NSArray *profileIds = @[ @"a-profile-id", @"another-profile-id" ];
NSString *alertContentJson = @"{\"body\":\"content of message\",\"title\":\"message title\"}";
NSString *customDataJson = @"{\"field1\":\"value1\",\"field2\":\"value2\"}";
BCCompletionBlock successBlock; // define callback
BCErrorCompletionBlock failureBlock; // define callback
[[_bc pushNotificationService] sendNormalizedPushNotificationBatch:profileIds
alertContentJson:alertContentJson
customDataJson:customDataJson
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
String[] profileIds = { "a-profile-id", "another-profile-id" };
String alertContentJson = "{\"body\":\"content of message\",\"title\":\"message title\"}";
String customDataJson = "{\"field1\":\"value1\",\"field2\":\"value2\"}";
this; // implements IServerCallback
_bc.getPushNotificationService().sendNormalizedPushNotificationBatch(profileIds, alertContentJson, customDataJson, this);
public void serverCallback(ServiceName serviceName, ServiceOperation serviceOperation, JSONObject jsonData)
{
System.out.print(String.format("Success | %s", jsonData.toString()));
}
public void serverError(ServiceName serviceName, ServiceOperation serviceOperation, int statusCode, int reasonCode, String jsonError)
{
System.out.print(String.format("Failed | %d %d %s", statusCode, reasonCode, jsonError.toString()));
}
var profileIds = [ "a-profile-id", "another-profile-id" ];
var alertContentJson = {
"body": "content of message",
"title": "message title"
};
var customDataJson = {
"field1": "value1",
"field2": "value2"
};
_bc.pushNotification.sendNormalizedPushNotificationBatch(profileIds, alertContentJson, customDataJson, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});
var profileIds = [ "a-profile-id", "another-profile-id" ];
var alertContentJson = {
"body": "content of message",
"title": "message title"
};
var customDataJson = {
"field1": "value1",
"field2": "value2"
};
ServerResponse result = await _bc.pushNotificationService.sendNormalizedPushNotificationBatch(profileIds:profileIds, alertContent:alertContentJson, customData:customDataJson);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
var profileIds = [ "a-profile-id", "another-profile-id" ];
var alertContentJson = {
"body": "content of message",
"title": "message title"
};
var customDataJson = {
"field1": "value1",
"field2": "value2"
};
var pushNotificationProxy = bridge.getPushNotificationServiceProxy();
var postResult = pushNotificationProxy.sendNormalizedPushNotificationBatch(profileIds, alertContentJson, customDataJson);
if (postResult.status == 200) {
// Success!
}
{
"service": "pushNotification",
"operation": "SEND_NORMALIZED_BATCH",
"data": {
"profileIds": [
"the-profile-id",
"another-profile-id"
],
"alertContent": {
"body": "content of message",
"title": "message title"
},
"customData": {
"field1": "value1",
"field2": "value2"
}
}
}
JSON Response
{
"status": 200,
"data": null
}