Skip to main content
Advanced features provide developers with the ability to extend WuKongIM iOS SDK, including custom message types, attachment message handling, and other enterprise-level functionality.

Custom Messages

Custom Regular Messages

We’ll use creating a custom GIF message as an example to demonstrate how to create custom message types.

Step 1: Inherit WKMessageContent and Define Message Structure

Step 2: Encoding and Decoding

The final message content will be {"type":3,"url":"xxxx","width":xxx,"height":xxx}

Step 3: Register Custom Message

Step 4: Send Custom Message

Custom Attachment Messages

For messages that need to upload files (like images, videos, audio), you need to inherit from WKMediaMessageContent.

Example: Custom Video Message

Message Extensions

Message Reactions

Add reaction functionality to messages:

Message Replies

Implement message reply functionality:

Advanced Configuration

Message Encryption

Enable end-to-end encryption for messages:

Message Persistence Control

Control message storage behavior:

Performance Optimization

Message Caching

Optimize message loading performance:

Batch Operations

Perform batch operations for better performance:

Error Handling

Advanced Error Handling

Implement comprehensive error handling:

Best Practices

  1. Custom Message Types: Use unique type IDs to avoid conflicts
  2. Memory Management: Properly manage memory for large attachments
  3. Error Handling: Implement comprehensive error handling for all operations
  4. Performance: Use batch operations for multiple messages
  5. Security: Enable encryption for sensitive communications
  6. Caching: Configure appropriate cache settings for your use case