Once authenticated, users can send or receive messages such as text, photo, video, audio, location, contact... To send a message contains media content (photo, video, audio, file...), you need to upload media content to your server first. Then you use Stringee Flutter Plugin to send the uploaded URL.
Instantiate a text message by calling:
StringeeMessage msg = = StringeeMessage.typeText(text);
In which:
To instantiate other types of the message, you call:
///Photo
StringeeMessage msg = = StringeeMessage.typePhoto(filePath);
///Video
StringeeMessage msg = = StringeeMessage.typeVideo(filePath, duration);
///Audio
StringeeMessage msg = = StringeeMessage.typeAudio(filePath, duration);
///File
StringeeMessage msg = = StringeeMessage.typeFile(filePath);
///Link
StringeeMessage msg = = StringeeMessage.typeLink(text);
///Location
StringeeMessage msg = = StringeeMessage.typeLocation(latitude, longitude);
///Contact
StringeeMessage msg = = StringeeMessage.typeContact(vcard);
///Sticker
StringeeMessage msg = = StringeeMessage.typeSticker(stickerCategory, stickerName);
After creating a StringeeMessage, call _conversation.sendMessage(msg) to send a message StringeeMessage msg = = StringeeMessage.typeText(text);
_conversation.sendMessage(msg).then((value) {
print("status-" + value['status'] + " code-" + value['code'] + " message-" + value['message']);
});
Before you can send/receive a sticker message, 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:
To get local messages of a conversation, you call:
_conversation.getLocalMessages(count).then((value) {
print("status-" + value['status'] + " code-" + value['code'] + " message-" + value['message']);
List<StringeeMessage> msgs = value['body'];
});
In which:
To get latest messages from Stringee server, you call:
_conversation.getLastMessages(count).then((value) {
print("status-" + value['status'] + " code-" + value['code'] + " message-" + value['message']);
List<StringeeMessage> msgs = value['body'];
});
In which:
To get a list of messages tied to a conversation from server which have a sequence greater than seq, you call:
_conversation.getMessagesAfter(count, seq).then((value) {
print("status-" + value['status'] + " code-" + value['code'] + " message-" + value['message']);
List<StringeeMessage> msgs = value['body'];
});
In which:
To get a list of messages tied to a conversation from server which have a sequence smaller than seq, you call:
_conversation.getMessagesBefore(count, seq).then((value) {
print("status-" + value['status'] + " code-" + value['code'] + " message-" + value['message']);
List<StringeeMessage> msgs = value['body'];
});
In which:
Stringee tracks the recipient status of each message. There are five possible statuses in MsgState: initialize, sending, sent, delivered, read. Stringee automatically updates the recipient status to send, delivered. The only update your app can perform is to mark a conversation's messages as read:
_conversation.markAsRead().then((value) {
print("status-" + value['status'] + " code-" + value['code'] + " message-" + value['message']);
});
Stringee notify you the status update of a message via event DidReceiveObjectChange of StringeeClient.
To delete messages, you call:
_conversation.deleteMessages(msgIds).then((value) {
print("status-" + value['status'] + " code-" + value['code'] + " message-" + value['message']);
});
In which:
To pin or unpin a message, you call:
_conversation.pinOrUnPin(pinOrUnPin).then((value) {
print("status-" + value['status'] + " code-" + value['code'] + " message-" + value['message']);
});
In which: