SDKsiOS
Set the conversation extension field
Set a conversation extension field with OpenIM iOS SDK.
Attach custom business metadata to a conversation using setConversationEx:ex:onSuccess:onFailure:.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | NSString * | Yes | Target conversation identifier. |
ex | NSString * | Yes | Custom 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
exproperty into local conversation records usingconversationIDas the entity key. - Asynchronous event listening: Multi-device clients observe updates via
onConversationChanged:inOIMConversationListener(see Retrieve the conversation list). - Re-query calibration: To restore authoritative conversation metadata, invoke Retrieve conversations by ID.
Was this page helpful?