Platform note — code samples below use TypeScript. Every method has an equivalent in the iOS (Swift), Android (Kotlin), and Flutter (Dart) SDKs — see the linked SDK reference in each step.
Rich media messages—images, voice clips, videos, and file attachments—dramatically increase engagement and are expected in any modern chat UI. social.plus handles uploading, storage, and delivery so you only need to manage the user’s file picker and the message creation call.
Prerequisites: Basic message sending is working → Sending Messages
The custom dataType lets you send any JSON payload. Use it for link previews, poll cards, system events, or any structured message type your app needs.
// Link previewawait MessageRepository.createMessage({ subChannelId: channelId, dataType: 'custom', data: { type: 'link_preview', url: 'https://amity.co', title: 'Amity — Build Social Features', description: 'The platform for adding social features to your app.', thumbnailFileId: thumbnailId, },});// Pollawait MessageRepository.createMessage({ subChannelId: channelId, dataType: 'custom', data: { type: 'poll', question: 'What feature do you want next?', options: ['Dark mode', 'Voice chat', 'Threads'], },});
Your client app must know how to render each custom type. The social.plus SDK delivers the raw JSON — the UI rendering is your responsibility.
Enable AI image moderation in Admin Console → AI Content Moderation to automatically flag or block NSFW images in chat before other users see them.→ AI Content Moderation
File size and type policy
Configure allowed file types and maximum file sizes in Admin Console → Network Settings. The SDK enforces these limits client-side before uploading.→ Network Settings
Sending fileId before the upload completes — Always await the upload call and check for errors before calling createMessage. A partially-uploaded file will produce a broken message that can’t be recovered.
Storing file URLs directly — File URLs from the social.plus CDN are signed and expire. Always store the fileId in your database, not the URL. Regenerate download URLs on demand.
For videos and large files, display a progress bar during upload. This prevents the user from thinking the send button is broken on slow connections. The file upload callback provides a progress percentage (0–100).
Compress images before upload
Compress images to ≤ 2MB before uploading. High-res photos degrade channel load times for all members and increase storage costs. Apply client-side compression in the file picker.
Use custom type for rich cards
For complex UI elements (polls, product cards, event invites), use the custom dataType with a versioned type field. This lets you iterate on card designs server-side without forcing app updates.
Dive deeper: Messaging API Reference has full parameter tables, method signatures, and platform-specific details for every API used in this guide.