I am creating a chat app using Smack XMPP. Everything is working good except the Read/Deliver reports.
This is how I am sending delivery report:
{
Message message = new Message();
message.setTo(chatMessage.getReceiver());
message.setType(Message.Type.normal);
message.setFrom(chatMessage.getSender());
message.setStanzaId(chatMessage.getReceiver() + "_" + CommonMethods.getCurrentGMTTime(0));
ChatMarker_File_XMPP_SERVER chatMarker_file_xmpp_server=new ChatMarker_File_XMPP_SERVER("received","urn:xmpp:chat-markers:0" , true);
chatMarker_file_xmpp_server.setIdValue(chatMessage.getMsgid());
message.addExtension(chatMarker_file_xmpp_server);
Mychat = ChatManager.getInstanceFor(connection).createChat(
message.getTo() + "@"
+ context.getString(R.string.server),
mMessageListener);
try {
if (connection.isAuthenticated()) {
/********************************************************
* ******** MESSAGE SEND **********************
***/
Mychat.sendMessage(message);
} else {
login();
}
} catch (SmackException.NotConnectedException e) {
Log.e("xmpp.SendMessage()", "msg Not sent!-Not Connected!");
} catch (Exception e) {
Log.e("SendMessage()-Exception",
"msg Not sent!" + e.getMessage());
}
}
But the issue is Mychat.sendMessage(message);
the SendMessage
method is doing this
/**
* Sends a message to the other chat participant. The thread ID, recipient,
* and message type of the message will automatically set to those of this chat.
*
* @param message the message to send.
* @throws NotConnectedException
*/
public void sendMessage(Message message) throws NotConnectedException {
// Force the recipient, message type, and thread ID since the user elected
// to send the message through this chat object.
message.setTo(participant);
message.setType(Message.Type.chat);
message.setThread(threadID);
chatManager.sendMessage(this, message);
}
Now although I am explicitly setting 'messageType' to 'normal' but the 'sendMessage()' is converting it again to Type.Chat
.
I have checked the other possible methods and docs so that somehow I can send a Message with Type normal but couldn't find any thing.
Thanks