I want to send
Smack surely has a better way to work with XML than this approach with modifying the string representation. This will break badly when anything contains a "
or any of the other characters that need to be escaped as an attribute.
You have to add custom payloads to messages as a separate XML element within the message, not as attributes on the message. Your XML should look like:
<message id="qm5Dx-8" to="abc" type="chat" from="abc">
<body>Image</body>
<request xmlns='urn:xmpp:receipts'/>
<data xmlns='http://bstkaal/custom/data'
msgType="2"
msgTimeStamp="1413971599039"
fileSize="18 MB"
fileHeight="300"
fileWidth="300"
thumbnail="abc"
mediaURL=""
serverMediaURL="xyz"
isFromMe="1"
status="1" />
</message>
xnyhps answer is correct. I've just want to add a few things. He already said that, but I can't stress the fact enough, because I see it again and again:
Never add custom values to specified stream element attributes (e.g. a new value for the type attribute of messages), and never add new attributes to top level elements (like you did with msgType
, msgTimeStamp
and so on).
This has the potential to break things! Don't do it. See also "XEP-0134: XMPP Design Guidelines § 2.1 XMPP is Sacred". That's why it's not possible in Smack. Instead, use a custom extension element, like xnyhps showed in his example (the data
element). See also "RFC 6120 § 8.4 Extended Content" Those are called PacketExtension's in Smack.