Browse SDKs · iOS
Platform
SDKsiOS

Set the group extension field

Set an application-defined group extension string with OpenIM iOS SDK.

Copy

Invoke setGroupInfoDictionary:onSuccess:onFailure: to update custom application-defined extension data for a group (typically restricted to group owners and administrators):

Parameters

ParameterTypeRequiredDescription
groupInfoDictionaryNSDictionary *YesDictionary containing the target groupID and extension key-value pairs.

Dictionary keys

ParameterTypeRequiredDescription
groupIDNSString *YesTarget group ID.
exNSString *YesCustom extension string (such as serialized JSON). The write completely overwrites the existing value; preserve other module namespaces before saving.

Code example

NSDictionary *changes = @{
    @"groupID": groupID,
    @"ex": mergedExtensionJSON
};

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

Return value

The onSuccess callback returns confirmation when the server accepts the extension update.

State changes after the call

  1. Local state update: The client updates the local cached group's ex attribute matching groupID.
  2. Event notification: Group members receive an updated OIMGroupInfo object through the onGroupInfoChanged: listener callback.
  3. Re-query calibration: To calibrate local cache values, call getSpecifiedGroupsInfo:onSuccess:onFailure:. For listener setup, refer to Groups overview.