# 7.7 Add Group Members

The `addInGroup:groupMembers:success:failure:` function is used to add  new members to the Group. The members to be added in the group may belong to different companies, provided that the company and the member must already be registered with Bayun. Any existing member of the group can add new members. The developer can enforce stricter access-mechanisms on top if desired (e.g. only group-owner or group-admin is allowed to add new members).

The function takes the following parameters :

* **groupId**  :  GroupId of the group.
* **groupMembers**  : NSArray of `GroupMember`.
* **success** : Success block to be executed after members are added to the group.
* **failure** : Failure block to be executed if members could not be added to the group, returns `BayunError`.

{% tabs %}
{% tab title="Objective-C" %}

```objectivec
GroupMember *groupMember = [[GroupMember alloc] initWithCompanyName:@"<companyName>" companyEmployeeId:@"<companyEmployeeId>"];
[[BayunCore sharedInstance] addInGroup:@"<groupId>" groupMembers:@[groupMember] success:^{
  NSLog(@"Group member added successfully.");       
} failure:^(BayunError error) {
   NSLog(@"Error adding the group member");
}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
let groupMember : GroupMember = GroupMember(companyName:"<companyName>", companyEmployeeId: "<companyEmployeeId>")
 BayunCore.sharedInstance()?.add(inGroup: "<groupId>", groupMembers: [groupMember], success: {
  NSLog("Group member added successfully.")
 }, failure: { (error) in
  NSLog("Error adding the group member") 
})
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bayun.gitbook.io/bayuncoresdk-ios/6-groups/7.7-add-group-members.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
