Send a Message

Text message#

Text is a basic form of communication between users. sdk provides methods to send the text message to the end users. once the user has sent message via sdk, it will give callback with status. if you want send the text message for a user, you can utilise the below method.

To send your text message, you need to pass the MessageParams.text object as an argument to the parameter in the sendMessage() method.

var textMessage = MessageParams.text(
toJid: toJid,
replyMessageId: replyMessageId, // Optional
topicId: topicId, // Optional
metaData: metaData, // Optional
textMessageParams: TextMessageParams(messageText: messageText));
Mirrorfly.sendMessage(messageParams: textMessage, flyCallback: (response){
if(response.isSuccess){
}
});
ArgumentTypeDescription
messageParamsMessageParams.textObject to hold the parameters of the text message
flyCallbackFlyResponsecallback to observe the action status

Note : You can listen to incoming messages by using the onMessageReceived listener.

Image message#

To send image as a message call the below method. Calling the below method will upload the image file to the server provided during sdk initialization then send the message

To send your image message, you need to pass the MessageParams.image object as an argument to the parameter in the sendMessage() method.

var imageMessage = MessageParams.image(toJid: toJid,
replyMessageId: replyMessageId, //Optional
topicId: topicId, //Optional
metaData: metaData, // Optional
fileMessageParams: FileMessageParams(
file: File(imageFilePath),
caption: caption //Optional
));
Mirrorfly.sendMessage(messageParams: imageMessage, flyCallback: (response){
if(response.isSuccess){
}
});
ArgumentTypeDescription
messageParamsMessageParams.imageObject to hold the parameters of the image message
flyCallbackFlyResponsecallback to observe the action status

Note : You can listen for incoming media messages with the onMessageReceived event. Additionally, use the onMediaStatusUpdated event for status updates, and track upload/download progress using the onUploadDownloadProgressChanged event.

Note : In Mirrorfly.initializeSDK() storageFolderName should be defined to set your own local path to store app media files.

caution

If Image attachment feature unavailable for your plan then it will throw 403 exception.

Video message#

Video sharing is very useful communication between users. sdk provides methods to send the video message to the end users. once the user has sent message via sdk, it will give callback with status. if you want send the video message for a user, you can utilise the below method.

To send your video message, you need to pass the MessageParams.video object as an argument to the parameter in the sendMessage() method.

var videoMessage = MessageParams.video(toJid: toJid,
replyMessageId: replyMessageId, //Optional
topicId: topicId, //Optional
metaData: metaData, // Optional
fileMessageParams: FileMessageParams(
file: File(videoFilePath),
caption: caption //Optional
));
Mirrorfly.sendMessage(messageParams: videoMessage, flyCallback: (response){
if(response.isSuccess){
}
});
ArgumentTypeDescription
messageParamsMessageParams.videoObject to hold the parameters of the video message
flyCallbackFlyResponsecallback to observe the action status

Note : You can listen for incoming media messages with the onMessageReceived event. Additionally, use the onMediaStatusUpdated event for status updates, and track upload/download progress using the onUploadDownloadProgressChanged event.

Note : In Mirrorfly.initializeSDK() storageFolderName should be defined to set your own local path to store app media files.

caution

If Video attachment feature unavailable for your plan then it will throw 403 exception.

Audio message#

To send audio as a message call the below method. Calling the below method will upload the audio file to the server provided during sdk initialization then send the message

To send your audio message, you need to pass the MessageParams.audio object as an argument to the parameter in the sendMessage() method.

var audioMessage = MessageParams.audio(toJid: toJid,
isRecorded: `true` for recorded audio otherwise set `false`
replyMessageId: replyMessageId, //Optional
topicId: topicId, //Optional
metaData: metaData, // Optional
fileMessageParams: FileMessageParams(
file: File(audioFilePath)));
Mirrorfly.sendMessage(messageParams: audioMessage, flyCallback: (response){
if(response.isSuccess){
}
});
ArgumentTypeDescription
messageParamsMessageParams.audioObject to hold the parameters of the audio message
flyCallbackFlyResponsecallback to observe the action status

Note : You can listen for incoming media messages with the onMessageReceived event. Additionally, use the onMediaStatusUpdated event for status updates, and track upload/download progress using the onUploadDownloadProgressChanged event.

Note : In Mirrorfly.initializeSDK() storageFolderName should be defined to set your own local path to store app media files.

caution

If Audio attachment feature unavailable for your plan then it will throw 403 exception.

Document message#

Document sharing is very useful communication between users. sdk provides methods to send the document message to the end users. once the user has sent message via sdk, it will give callback with status. if you want send the document message for a user, you can utilise the below method.

To send your document message, you need to pass the MessageParams.document object as an argument to the parameter in the sendMessage() method.

var documentMessage = MessageParams.document(toJid: toJid,
replyMessageId: replyMessageId, //Optional
topicId: topicId, //Optional
metaData: metaData, // Optional
fileMessageParams: FileMessageParams(
file: File(documentFilePath)));
Mirrorfly.sendMessage(messageParams: documentMessage, flyCallback: (response){
if(response.isSuccess){
}
});
ArgumentTypeDescription
messageParamsMessageParams.documentObject to hold the parameters of the document message
flyCallbackFlyResponsecallback to observe the action status

Note : You can listen for incoming media messages with the onMessageReceived event. Additionally, use the onMediaStatusUpdated event for status updates, and track upload/download progress using the onUploadDownloadProgressChanged event.

Note : In Mirrorfly.initializeSDK() storageFolderName should be defined to set your own local path to store app media files.

caution

If Document attachment feature unavailable for your plan then it will throw 403 exception.

Location message#

Location sharing is a famous communication between users. sdk provides methods to send the location message to the end users. once the user has sent message via sdk, it will give callback with status. if you want send the location message for a user, you can utilise the below method.

To send your location message, you need to pass the MessageParams.location object as an argument to the parameter in the sendMessage() method.

var locationMessage = MessageParams.location(toJid: toJid,
replyMessageId: replyMessageId, //Optional
topicId: topicId, //Optional
metaData: metaData, // Optional
locationMessageParams: LocationMessageParams(latitude: latitude, longitude: longitude));
Mirrorfly.sendMessage(messageParams: locationMessage, flyCallback: (response){
if(response.isSuccess){
}
});
ArgumentTypeDescription
messageParamsMessageParams.locationObject to hold the parameters of the location message
flyCallbackFlyResponsecallback to observe the action status

Note : You can listen to incoming messages by using the onMessageReceived listener.

caution

If Location attachment feature unavailable for your plan then it will throw 403 exception.

Contact message#

Contact sharing is very useful communication between users. sdk provides methods to send the contact message to the end users. once the user has sent message via sdk, it will give callback with status. if you want send the contact message for a user, you can utilise the below method.

To send your contact message, you need to pass the MessageParams.contact object as an argument to the parameter in the sendMessage() method.

var contactMessage = MessageParams.contact(toJid: toJid,
replyMessageId: replyMessageID, //Optional
topicId: topicId, //Optional
metaData: metaData, // Optional
contactMessageParams: ContactMessageParams(name: contactName, numbers: contactNumbers));
Mirrorfly.sendMessage(messageParams: contactMessage, flyCallback: (response){
if(response.isSuccess){
}
});
ArgumentTypeDescription
messageParamsMessageParams.contactObject to hold the parameters of the contact message
flyCallbackFlyResponsecallback to observe the action status

Note : You can listen to incoming messages by using the onMessageReceived listener.

caution

If Contact attachment feature unavailable for your plan then it will throw 403 exception.