SendTemplatedPushNotificationToGroup
Sends a notification to a "group" of user based on a brainCloud portal configured notification template. Includes JSON defining the substitution params to use with the template.
The format of the parameterized string is based on the MessageFormat java class.
A typical parameterized string could be "Hello {1}, welcome to the {0} game."".
The substitution values are passed via a JSON structure as follows:
{ "1" : "George Smith", "0" : "Poker Pirates" }
Note that the key of the JSON object is the substitution variable number and the value is the substitution value.
The resulting string would be "Hello George Smith, welcome to the Poker Pirates game.".
Service | Operation |
---|---|
pushNotification | SEND_TEMPLATED_TO_GROUP |
Method Parameters
Parameter | Description |
---|---|
groupId | Target group ID |
notificationTemplateId | Id of the notification template |
substitutionJson | JSON defining the substitution params to use with the template |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
string groupId = "group1";
int notificationTemplateId = 1;
string substitutionsJson = "{\"0\":\"value0\",\"1\":\"value1\"}";
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.SendTemplatedPushNotificationToGroup(groupId, notificationTemplateId, substitutionsJson, successCallback, failureCallback);
const char *groupId = "group1";
int notificationTemplateId = 1;
const char *substitutionsJson = "{\"0\":\"value0\",\"1\":\"value1\"}";
_bc->getPushNotificationService()->sendTemplatedPushNotificationToGroup(groupId, notificationTemplateId, substitutionsJson, this);
NSString *groupId = @"group1";
int notificationTemplateId = 1;
NSString *substitutionsJson = @"{\"0\":\"value0\",\"1\":\"value1\"}";
BCCompletionBlock successBlock; // define callback
BCErrorCompletionBlock failureBlock; // define callback
[[_bc pushNotificationService] sendTemplatedPushNotificationToGroup:groupId
notificationTemplateId:notificationTemplateId
substitutionsJson:substitutionsJson
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
String groupId = "group1";
int notificationTemplateId = 1;
String substitutionsJson = "{\"0\":\"value0\",\"1\":\"value1\"}";
this; // implements IServerCallback
_bc.getPushNotificationService().sendTemplatedPushNotificationToGroup(groupId, notificationTemplateId, substitutionsJson, 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 groupId = "group1";
var notificationTemplateId = 1;
var substitutionsJson = {
"0": "value0",
"1": "value1"
};
_bc.pushNotification.sendTemplatedPushNotificationToGroup(groupId, notificationTemplateId, substitutionsJson, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});
var groupId = "group1";
var notificationTemplateId = 1;
var substitutionsJson = {
"0": "value0",
"1": "value1"
};
ServerResponse result = await _bc.pushNotificationService.sendTemplatedPushNotificationToGroup(groupId:groupId, notificationTemplateId:notificationTemplateId, substitutions:substitutionsJson);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
var groupId = "group1";
var notificationTemplateId = 1;
var substitutionsJson = {
"0": "value0",
"1": "value1"
};
var pushNotificationProxy = bridge.getPushNotificationServiceProxy();
var postResult = pushNotificationProxy.sendTemplatedPushNotificationToGroup(groupId, notificationTemplateId, substitutionsJson);
if (postResult.status == 200) {
// Success!
}
{
"service": "pushNotification",
"operation": "SEND_TEMPLATED_TO_GROUP",
"data": {
"groupId": "group1",
"notificationTemplateId": 1,
"substitutions": {
"0": "value0",
"1": "value1"
}
}
}
JSON Response
{
"status": 200,
"data": null
}