Skip to content

Sending messages

tjuric edited this page Aug 12, 2016 · 28 revisions

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

MO messages sent from users' smartphone are forwarded to your own server. 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.

###Sending messages with custom data

Use following API to send messages from mobile device:

MoMessage message = new MoMessage();
message.setDestination("destination_identifier");
message.setText("This is my mobile-originated message!");

Map<String, Object> customPayload = new HashMap<>();
customPayload.put("custom_key_1_string", "string_value");
customPayload.put("custom_key_2_number", 1);
customPayload.put("custom_key_3_boolean", true);
message.setCustomPayload(customPayload);

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

###Receiving sent message status

Register BroadcastReceiver in order to receive status information about each sent message as desribed in MESSAGES_SENT event.

Clone this wiki locally