Once authenticated, users can send or receive messages such as text, photo, video, audio, location, and contact. For media messages, pass the local filePath to the corresponding StringeeMessage constructor; the Stringee Flutter Plugin uploads the attachment when _conversation.sendMessage(...) is called.
Instantiate a text message by calling:
StringeeMessage msg = StringeeMessage.typeText(client, text);
In which:
To instantiate other types of the message, you call:
///Photo
StringeeMessage msg = StringeeMessage.typePhoto(client, filePath);
///Video
StringeeMessage msg = StringeeMessage.typeVideo(client, filePath, duration);
///Audio
StringeeMessage msg = StringeeMessage.typeAudio(client, filePath, duration);
///File
StringeeMessage msg = StringeeMessage.typeFile(client, filePath);
///Link
StringeeMessage msg = StringeeMessage.typeLink(client, text);
///Location
StringeeMessage msg = StringeeMessage.typeLocation(client, latitude, longitude);
///Contact
StringeeMessage msg = StringeeMessage.typeContact(client, vcard);
///Sticker
StringeeMessage msg = StringeeMessage.typeSticker(client, stickerCategory, stickerName);
After creating a StringeeMessage, call _conversation.sendMessage(msg) to send it:
StringeeMessage msg = StringeeMessage.typeText(client, 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 message states to sent and delivered. The update your app performs is marking a conversation's messages as read:
_conversation.markAsRead().then((value) {
print("status-${value['status']} code-${value['code']} message-${value['message']}");
});
Stringee reports message status updates through StringeeChatEvents.didReceiveObjectChange on the StringeeChat object.
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:
msg.pinOrUnPin(pinOrUnPin).then((value) {
print("status-${value['status']} code-${value['code']} message-${value['message']}");
});
In which: