Once authenticated, users can send or receive messages such as text, photos, videos, audio, locations, and contacts. For media messages, provide a local file path on the device; the Stringee SDK uploads the attachment when conversation.sendMessage(...) is called.
Instantiate a text message by calling:
Message message = new Message(text);
In which:
To instantiate the other types of message, you call:
Message message = new Message(Message.Type.PHOTO);
In which:
Message.Type enum value.Following message types are supported:
Message.Type.TEXTMessage.Type.PHOTOMessage.Type.VIDEOMessage.Type.AUDIOMessage.Type.FILEMessage.Type.LOCATIONMessage.Type.CONTACTMessage.Type.STICKERMessage message = new Message(text);
conversation.sendMessage(stringeeClient, message, new StatusListener() {
@Override
public void onSuccess() {
}
@Override
public void onError(StringeeError error) {
}
});
Message message = new Message(Message.Type.PHOTO); // PHOTO, AUDIO, VIDEO, or FILE
message.setFilePath(filepath); // The path of the attachment on your device
message.setDuration(duration); // For Audio, Video Message, in milisecond
conversation.sendMessage(stringeeClient, message, new StatusListener() {
@Override
public void onSuccess() {
}
@Override
public void onError(StringeeError error) {
}
});
Message message = new Message(Message.Type.LOCATION);
message.setLatitude(latitude);
message.setLongitude(longitude);
conversation.sendMessage(stringeeClient, message, new StatusListener() {
@Override
public void onSuccess() {
}
@Override
public void onError(StringeeError error) {
}
});
Message message = new Message(Message.Type.CONTACT);
message.setContact(vCardContact); // Send a contact in vcard format
conversation.sendMessage(stringeeClient, message, new StatusListener() {
@Override
public void onSuccess() {
}
@Override
public void onError(StringeeError error) {
}
});
Message message = new Message(Message.Type.STICKER);
message.setStickerCategory(category);
message.setStickerName(name);
conversation.sendMessage(stringeeClient, message, new StatusListener() {
@Override
public void onSuccess() {
}
});
Before you can send/receive a sticker, you must upload sticker sets to your server first.
Messages are stored on Stringee server and cached on the local database as well. You can get messages as follows:
Get local messages of a conversation by calling:
conversation.getLocalMessages(stringeeClient, count, new CallbackListener<List<Message>>() {
@Override
public void onSuccess(List<Message> messageList) {
}
});
In which:
Get the latest messages from the Stringee server by calling:
conversation.getLastMessages(stringeeClient, count, new CallbackListener<List<Message>>() {
@Override
public void onSuccess(final List<Message> messages1) {
}
});
In which:
Get a list of messages tied to a conversation from the server which has a sequence greater than seq by calling:
conversation.getMessagesAfter(stringeeClient, seq, count, new CallbackListener<List<Message>>() {
@Override
public void onSuccess(final List<Message> lstMessages) {
}
});
In which:
Get a list of messages tied to a conversation from the server which has a sequence smaller than seq by calling:
conversation.getMessagesBefore(stringeeClient, seq, count, new CallbackListener<List<Message>>() {
@Override
public void onSuccess(final List<Message> lstMessages) {
}
});
In which:
Stringee keeps track of the delivery status of each message to the recipient. There are five possible statuses: INITIALIZED, SENDING, SENT, DELIVERED, READ. Stringee automatically updates the recipient status to SENT and DELIVERED. The only update your app can perform is marking a conversation's messages as read:
conversation.markAllAsRead(stringeeClient, new StatusListener() {
@Override
public void onSuccess() {
}
});
Stringee will notify you of the status update of a message via the onChangeEvent event of StringeeClient.
Delete messages by calling:
JSONArray messageIds = new JSONArray();
messageIds.put(messageId);
conversation.deleteMessages(stringeeClient, messageIds, new StatusListener() {
@Override
public void onSuccess() {
}
@Override
public void onError(StringeeError error) {
}
});
In which:
JSONArray containing the IDs of messages to delete.Pin or unpin a message by calling:
message.pinOrUnpin(stringeeClient, pinOrUnpin, new StatusListener() {
@Override
public void onSuccess() {
}
@Override
public void onError(StringeeError error) {
}
});
In which: