setGroupAttributes method

Future<V2TimCallback> setGroupAttributes({
  1. required String groupID,
  2. required Map<String, String> attributes,
})

Implementation

Future<V2TimCallback> setGroupAttributes({
  required String groupID,
  required Map<String, String> attributes,
}) async {
  if (!TIMManager.instance.isInitSDK()) {
    return V2TimCallback(code: TIMErrCode.ERR_SDK_NOT_INITIALIZED.value, desc: "sdk not init");
  }

  String userData = Tools.generateUserData('setGroupAttributes');
  Completer<V2TimCallback> completer = Completer();
  NativeLibraryManager.timCallback2Future(userData, completer);

  Pointer<Char> pGroupID = Tools.string2PointerChar(groupID);
  List<Map<String, dynamic>> jsonAttributesList = Tools.map2JsonList(attributes, 'group_attribute_key', 'group_attribute_value');
  Pointer<Char> pAttributes = Tools.string2PointerChar(json.encode(jsonAttributesList));
  Pointer<Void> pUserData = Tools.string2PointerVoid(userData);
  NativeLibraryManager.bindings.DartSetGroupAttributes(pGroupID, pAttributes, pUserData);

  return completer.future;
}