SysSendMessage
tip
This method is available in Cloud Code scripts only.
Sends a message on behalf of the system (i.e. app) to the specified users.
Service | Operation |
---|---|
messaging | SYS_SEND_MESSAGE |
Method Parameters
Parameter | Description |
---|---|
toProfileIds | The array of recipients |
contentJson | The json content object to send in the message |
fromJson | Who the message is from. Should contain at least "name" field, and potential "pic" field as well. |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
var toProfileIds = [ "profileId1", "profileId2" ];
var contentJson = {
"subject": "Upcoming features!",
"text": "Chat and messaging features are here!"
};
var fromJson = {
"id": null,
"name": "App Administrator"
};
var messagingProxy = bridge.getMessagingServiceProxy();
var postResult = messagingProxy.sysSendMessage(toProfileIds, contentJson, fromJson);
if (postResult.status == 200) {
// Success!
}
{
"service": "messaging",
"operation": "SYS_SEND_MESSAGE",
"data": {
"toProfileIds": [
"profileId1",
"profileId2"
],
"contentJson": {
"subject": "Upcoming features!",
"text": "Chat and messaging features are here!"
},
"fromJson": {
"id": null,
"name": "App Administrator"
}
}
}
JSON Response
{
"status": 200,
"data": {
}
}
Common Error Code
Status Codes
Code | Name | Description |
---|---|---|
40601 | FEATURE_NOT_ENABLED | Messaging feature is not enabled for app. |