SendMessageSimple
Sends a simple string-based message on behalf of the user.
Service | Operation |
---|---|
messaging | SEND_MESSAGE_SIMPLE |
Method Parameters
Parameter | Description |
---|---|
toProfileIds | An array of recipients of the message. |
text | The text to send. |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
string[] toProfileIds = { "profileId1", "profileId2" };
string text = "Chat and messaging features are here!";
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.MessagingService.SendMessageSimple(toProfileIds, text, successCallback, failureCallback);
std::vector<std::string> toProfileIds;
toProfileIds.push_back("profileId1");
toProfileIds.push_back("profileId2");
const char *text = "Chat and messaging features are here!";
_bc->getMessagingService()->sendMessageSimple(toProfileIds, text, this);
NSArray *toProfileIds = @[ @"profileId1", @"profileId2" ];
NSString *text = @"Chat and messaging features are here!";
BCCompletionBlock successBlock; // define callback
BCErrorCompletionBlock failureBlock; // define callback
[[_bc messagingService] sendMessageSimple:toProfileIds
text:text
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
String[] toProfileIds = { "profileId1", "profileId2" };
String text = "Chat and messaging features are here!";
this; // implements IServerCallback
_bc.getMessagingService().sendMessageSimple(toProfileIds, text, 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 toProfileIds = [ "profileId1", "profileId2" ];
var text = "Chat and messaging features are here!";
_bc.messaging.sendMessageSimple(toProfileIds, text, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});
var toProfileIds = [ "profileId1", "profileId2" ];
var text = "Chat and messaging features are here!";
ServerResponse result = await _bc.messagingService.sendMessageSimple(toProfileIds:toProfileIds, text:text);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
var toProfileIds = [ "profileId1", "profileId2" ];
var text = "Chat and messaging features are here!";
var messagingProxy = bridge.getMessagingServiceProxy();
var postResult = messagingProxy.sendMessageSimple(toProfileIds, text);
if (postResult.status == 200) {
// Success!
}
{
"service": "messaging",
"operation": "SEND_MESSAGE_SIMPLE",
"data": {
"toProfileIds": [
"profileId1",
"profileId2"
],
"text": "Chat and messaging features are here!"
}
}
JSON Response
{
"status": 200,
"data": {
"actual": 1,
"requested": 1,
"msgId": "cf56f676-1f8e-40f7-9546-1efd7746f940"
}
}
Common Error Code
Status Codes
Code | Name | Description |
---|---|---|
40601 | FEATURE_NOT_ENABLED | Messaging feature is not enabled for app. |