SendRawPushNotificationBatch
Sends a notification to a list of users consisting of raw message content.
Service | Operation |
---|---|
pushNotification | SEND_RAW_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 fcmContent = "{\"notification\":{\"body\":\"content of message\",\"title\":\"message title\"},\"data\":{\"customfield1\":\"customValue1\",\"customfield2\":\"customValue2\"},\"priority\":\"normal\"}";
string iosContent = "{\"aps\":{\"alert\":{\"body\":\"content of message\",\"title\":\"message title\"},\"badge\":0,\"sound\":\"gggg\"}}";
string facebookContent = "{\"template\":\"content of message\"}";
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.SendRawPushNotificationBatch(profileIds, fcmContent, iosContent, facebookContent, successCallback, failureCallback);
std::vector<std::string> profileIds;
profileIds.push_back("a-profile-id");
profileIds.push_back("another-profile-id");
const char *fcmContent = "{\"notification\":{\"body\":\"content of message\",\"title\":\"message title\"},\"data\":{\"customfield1\":\"customValue1\",\"customfield2\":\"customValue2\"},\"priority\":\"normal\"}";
const char *iosContent = "{\"aps\":{\"alert\":{\"body\":\"content of message\",\"title\":\"message title\"},\"badge\":0,\"sound\":\"gggg\"}}";
const char *facebookContent = "{\"template\":\"content of message\"}";
_bc->getPushNotificationService()->sendRawPushNotificationBatch(profileIds, fcmContent, iosContent, facebookContent, this);
NSArray *profileIds = @[ @"a-profile-id", @"another-profile-id" ];
NSString *fcmContent = @"{\"notification\":{\"body\":\"content of message\",\"title\":\"message title\"},\"data\":{\"customfield1\":\"customValue1\",\"customfield2\":\"customValue2\"},\"priority\":\"normal\"}";
NSString *iosContent = @"{\"aps\":{\"alert\":{\"body\":\"content of message\",\"title\":\"message title\"},\"badge\":0,\"sound\":\"gggg\"}}";
NSString *facebookContent = @"{\"template\":\"content of message\"}";
BCCompletionBlock successBlock; // define callback
BCErrorCompletionBlock failureBlock; // define callback
[[_bc pushNotificationService] sendRawPushNotificationBatch:profileIds
fcmContent:fcmContent
iosContent:iosContent
facebookContent:facebookContent
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
String[] profileIds = { "a-profile-id", "another-profile-id" };
String fcmContent = "{\"notification\":{\"body\":\"content of message\",\"title\":\"message title\"},\"data\":{\"customfield1\":\"customValue1\",\"customfield2\":\"customValue2\"},\"priority\":\"normal\"}";
String iosContent = "{\"aps\":{\"alert\":{\"body\":\"content of message\",\"title\":\"message title\"},\"badge\":0,\"sound\":\"gggg\"}}";
String facebookContent = "{\"template\":\"content of message\"}";
this; // implements IServerCallback
_bc.getPushNotificationService().sendRawPushNotificationBatch(profileIds, fcmContent, iosContent, facebookContent, 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 fcmContent = {
"notification": {
"body": "content of message",
"title": "message title"
},
"data": {
"customfield1": "customValue1",
"customfield2": "customValue2"
},
"priority": "normal"
};
var iosContent = {
"aps": {
"alert": {
"body": "content of message",
"title": "message title"
},
"badge": 0,
"sound": "gggg"
}
};
var facebookContent = {
"template": "content of message"
};
_bc.pushNotification.sendRawPushNotificationBatch(profileIds, fcmContent, iosContent, facebookContent, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});
var profileIds = [ "a-profile-id", "another-profile-id" ];
var fcmContent = {
"notification": {
"body": "content of message",
"title": "message title"
},
"data": {
"customfield1": "customValue1",
"customfield2": "customValue2"
},
"priority": "normal"
};
var iosContent = {
"aps": {
"alert": {
"body": "content of message",
"title": "message title"
},
"badge": 0,
"sound": "gggg"
}
};
var facebookContent = {
"template": "content of message"
};
ServerResponse result = await _bc.pushNotificationService.sendRawPushNotificationBatch(profileIds:profileIds, fcmContent:fcmContent, iosContent:iosContent, facebookContent:facebookContent);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
var profileIds = [ "a-profile-id", "another-profile-id" ];
var fcmContent = {
"notification": {
"body": "content of message",
"title": "message title"
},
"data": {
"customfield1": "customValue1",
"customfield2": "customValue2"
},
"priority": "normal"
};
var iosContent = {
"aps": {
"alert": {
"body": "content of message",
"title": "message title"
},
"badge": 0,
"sound": "gggg"
}
};
var facebookContent = {
"template": "content of message"
};
var pushNotificationProxy = bridge.getPushNotificationServiceProxy();
var postResult = pushNotificationProxy.sendRawPushNotificationBatch(profileIds, fcmContent, iosContent, facebookContent);
if (postResult.status == 200) {
// Success!
}
{
"service": "pushNotification",
"operation": "SEND_RAW_BATCH",
"data": {
"profileIds": [
"the-profile-id",
"another-profile-id"
],
"fcmContent": {
"notification": {
"body": "content of message",
"title": "message title"
},
"data": {
"customfield1": "customValue1",
"customfield2": "customValue2"
},
"priority": "normal"
},
"iosContent": {
"aps": {
"alert": {
"body": "content of message",
"title": "message title"
},
"badge": 0,
"sound": "gggg"
}
},
"facebookContent": {
"template": "content of message"
}
}
}
JSON Response
{
"status": 200,
"data": null
}