Once authenticated, users can send or receive messages such as text, photos, videos, audio, locations, contacts... In order to send a message containing media content (photos, videos, audio, etc.), first, you need to upload media content to your server. Then, you use Stringee SDK to send the uploaded URL.
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(type);
In which:
Following message types are supported:
Message message = new Message(text);
conversation.sendMessage(stringeeClient, message, new StatusListener() {
@Override
public void onSuccess() {
}
@Override
public void onError(StringeeError error) {
}
});
Message message = new Message(type); // Photo, Audio, Video, File Message
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(type);
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(type);
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(type);
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:
message.markAsRead(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:
conversation.deleteMessages(stringeeClient, messages, new StatusListener() {
@Override
public void onSuccess() {
}
@Override
public void onError(StringeeError error) {
}
});
In which:
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: