Skip to content

Sending messages

Andrey Kadochnikov edited this page Dec 13, 2017 · 28 revisions

Mobile Messaging library provides the ability to send inbound messages from mobile device, also known as Mobile Originated (MO) messages.

MO messages sent from users' smartphone can be forwarded by our system to your own server. To activate the service please follow the configuration setup and action setup.

Once your server receives an MO message, it’s up to its' logic to identify the message recipient (destination identifier) and what to do with data received from mobile devices. Destination identifier might be any string you choose to define as the wanted destination of your MO message.

NOTE: Please, follow the instructions linked above for configuring MO forward action. Without this configuration you won't be able to receive MO messages on your server

Sending messages - mobile implementation

Sending messages with custom payload

Following example code shows how you can send MO messages from mobile device:

Message message = new Message();
message.setDestination("jgbh-r#HJbtyx7ny3ugd-34fhj3LKjl");
message.setBody("This is my mobile-originated message!");

JSONObject customPayload = new JSONObject();
customPayload.put("order_name", "pizza_capriciossa");
customPayload.put("rushed_delivery", true);
customPayload.put("coupon_number", 44869320);
message.setCustomPayload(customPayload);

MobileMessaging.getInstance(context).sendMessages(message);

Receiving sent message status

You can receive message status using two methods:

  1. supply ResultListener of MobileMessaging;
  2. register BroadcastReceiver in order to receive status information about each sent message as described in MESSAGES_SENT event.

Receiving messages - server implementation

After you've configured desired MO actions your server is able to receive sent inbound messages.

Troubleshooting

An error "Push MO route is not available for your account. Please contact your account manager." (HTTP status code 403) may be received in response to attempt to send a message from mobile device. Contact your account manager to address the issue.

Clone this wiki locally