SendNormalizedPushNotification
Sends a notification to a user consisting of alert content and custom data.
Service | Operation |
---|---|
pushNotification | SEND_NORMALIZED |
Method Parameters
Parameter | Description |
---|---|
toProfileId | The profileId of the user to receive the notification |
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 toProfileId = "profile1";
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.SendNormalizedPushNotification(toProfileId, alertContentJson, customDataJson, successCallback, failureCallback);
const char *toProfileId = "profile1";
const char *alertContentJson = "{\"body\":\"content of message\",\"title\":\"message title\"}";
const char *customDataJson = "{\"field1\":\"value1\",\"field2\":\"value2\"}";
_bc->getPushNotificationService()->sendNormalizedPushNotification(toProfileId, alertContentJson, customDataJson, this);
NSString *toProfileId = @"profile1";
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] sendNormalizedPushNotification:toProfileId
alertContentJson:alertContentJson
customDataJson:customDataJson
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
String toProfileId = "profile1";
String alertContentJson = "{\"body\":\"content of message\",\"title\":\"message title\"}";
String customDataJson = "{\"field1\":\"value1\",\"field2\":\"value2\"}";
this; // implements IServerCallback
_bc.getPushNotificationService().sendNormalizedPushNotification(toProfileId, 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 toProfileId = "profile1";
var alertContentJson = {
"body": "content of message",
"title": "message title"
};
var customDataJson = {
"field1": "value1",
"field2": "value2"
};
_bc.pushNotification.sendNormalizedPushNotification(toProfileId, alertContentJson, customDataJson, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});
var toProfileId = "profile1";
var alertContentJson = {
"body": "content of message",
"title": "message title"
};
var customDataJson = {
"field1": "value1",
"field2": "value2"
};
ServerResponse result = await _bc.pushNotificationService.sendNormalizedPushNotification(profileId:toProfileId, alertContent:alertContentJson, customData:customDataJson);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
var toProfileId = "profile1";
var alertContentJson = {
"body": "content of message",
"title": "message title"
};
var customDataJson = {
"field1": "value1",
"field2": "value2"
};
var pushNotificationProxy = bridge.getPushNotificationServiceProxy();
var postResult = pushNotificationProxy.sendNormalizedPushNotification(toProfileId, alertContentJson, customDataJson);
if (postResult.status == 200) {
// Success!
}
{
"service": "pushNotification",
"operation": "SEND_NORMALIZED",
"data": {
"toProfileId": "profile1",
"alertContent": {
"body": "content of message",
"title": "message title"
},
"customData": {
"field1": "value1",
"field2": "value2"
}
}
}
JSON Response
{
"status": 200,
"data": null
}