Browse SDKs · iOS
Platform
SDKsiOS

Set the conversation extension field

Set a conversation extension field with OpenIM iOS SDK.

Copy

Attach custom business metadata to a conversation using setConversationEx:ex:onSuccess:onFailure:.

Parameters

ParameterTypeRequiredDescription
conversationIDNSString *YesTarget conversation identifier.
exNSString *YesCustom extension string (typically JSON-formatted). Overwrites the existing field completely.

Code example

NSString *ex = @"{\"category\":\"work\",\"tag\":\"important\"}";

[[OIMManager manager] setConversationEx:@"c2c_user1002"
                                     ex:ex
                              onSuccess:^(NSString * _Nullable data) {
                                  NSLog(@"setConversationEx success");
                              }
                              onFailure:^(NSInteger code, NSString *message) {
                                  NSLog(@"setConversationEx failed: %ld %@", (long)code, message);
                              }];

The ex property is written as an atomic replacement string. The SDK does not parse or merge JSON keys on the client. To update specific keys without losing existing metadata, fetch the existing conversation snapshot first, merge your dictionary changes, and then submit the updated serialized string.

Return value

The onSuccess callback signifies that OpenIMServer processed the conversation extension update.

State changes after the call

  • Local state merge: Merge the new ex property into local conversation records using conversationID as the entity key.
  • Asynchronous event listening: Multi-device clients observe updates via onConversationChanged: in OIMConversationListener (see Retrieve the conversation list).
  • Re-query calibration: To restore authoritative conversation metadata, invoke Retrieve conversations by ID.