简体   繁体   中英

how to send image in messaging xmpp framework?

I'm sending only text, but I don't know how to send image/url, videos and integrate that in the chat application in iOS using XMPP.

I have refer so many questions but I want to send image using XEP-0363 I refer so many demo like monal app but any demo can't clear anything.

so Please help me.

There are a few ways to send images, one way is to create an API, and create a function for uploading images. So when you want to send an image, you can first call your API function, which will upload the image and then return the URL of the image. You can then send the URL in the <message> stanza, possibly in your own custom tags.

For example,

<message to=""...>
    <image>http://example.com/myimg.jpg</image>
</message>

Of course it will then be up to the client to download the image.

Another way to do it is to convert the image to a base64 string, and send the base64 string in the message stanza. However I actually do not recommend doing so, as the base64 string can be extremely large, and sending large packets through xmpp isn't a good idea. Particularly if you are in a group chat with a lot of users, in which case it will have to send the large packet to many users, wasting up valuable bandwidth, as well as server space for any offline-stored messages.

You could of course use XEP-0363 as mentioned, but you just need to make sure your XMPP server supports it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM