Groups

Create Groups

You can create and manage groups from the SDK and Dashboard. To create groups from the dashboard navigate to the Groups page and click on the New Group button.

Create Group - GetSocial Dashboard

Group creation needs the following information:

  1. Group ID: this is a unique id that you provide to identify the group
  2. Title / Description: Name of the Group and description that you can make visible to your users. You can also enable users to search and discover Groups by Group name. These can also be localized to 36+ supported languages.
  3. Icon: Group icon is optional. Icon can be displayed with name and description in the app
  4. Permissions: with group permissions you can define which users can post activity and interact with the group. Interaction includes comments and reactions. You can define who can post and interact with the group feeds i.e. all group members, admins or owner or some combination.
  5. Privacy: impacts who can join and access the feed and list members of the group
  6. Discoverability: determines if this group is visible when users search by group name
  7. Properties: additional metadata that you can add to the group e.g custom data that might define UI elements for group like group color.

To create groups from the SDK:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
val groupContent = GroupContent.create("sample_group")
    .withTitle("Sample Group")
    .withDescription("Shows how to create a group")
    .withAvatar(MediaAttachment.imageUrl(avatarUrl))
    // or attach an image
    .withAvatar(MediaAttachment.image(avatarImage))
    .withDiscoverable(true) // group will be visible for everyone
    .withPrivate(true) // joining requires approval
    .setPermission(CommunitiesAction.POST, Role.ADMIN) // only admins can create posts
    .setPermission(CommunitiesAction.REACT, Role.MEMBER) // members can add reactions

Communities.createGroup(groupContent, {result: Group ->  
    print("Group created: $result")
}, { error ->  
    print("Failed to create group, error: $error")
})      
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
let groupContent = GroupContent(groupId: "sample_group")
groupContent.title = "Sample Group"
groupContent.groupDescription = "Shows how to create a group"
groupContent.avatar = MediaAttachment.imageUrl(avatarUrl)
// or attach an image 
// groupContent.avatar = MediaAttachment.image(avatarImage)
groupContent.permissions[.post] = .admin // only admins can create posts
groupContent.permissions[.member] = .react // members can add reactions

groupContent.isDiscoverable = true // group will be visible for everyone
groupContent.isPrivate = true // joining requires approval

Communities.createGroup(groupContent, { group in
    print("Group created: \(group)")
}, failure: { error in
    print("Failed to create group: \(error)")
};
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
var groupContent = new GroupContent("sample_group");
groupContent.Title = "Sample Group";
groupContent.Description = "Shows how to create a group";
groupContent.Avatar = MediaAttachment.WithImageUrl(avatarUrl);
// or attach an image 
// groupContent.Avatar = MediaAttachment.withImage(avatarImage);
groupContent.AddPermission(CommunitiesAction.Post, MemberRole.Admin); // only admins can create posts
groupContent.AddPermission(CommunitiesAction.React, MemberRole.Member); // members can add reactions

groupContent.IsDiscoverable = true; // group will be visible for everyone
groupContent.IsPrivate = true; // joining requires approval

Communities.CreateGroup(groupContent, (group) => {
    Debug.Log("Group created: ", + group);
}, (error) => {
    Debug.Log("Failed to create group, error: " + error);
});
1
Coming soon...
1
Coming soon...

Get Groups

You can get a paginated list of all group in your application

1
2
3
4
5
6
7
8
val query = GroupsQuery.all()
val pagingQuery = PagingQuery(query)
Communities.getGroups(pagingQuery, { result: PagingResult<Group> ->
    val group = result.entries
    print("Groups: $groups")
}, { error: GetSocialError ->
    print("Failed to get list of groups: $error")
})
1
2
3
4
5
6
7
let query = GroupsQuery.all()
let pagingQuery = GroupsPagingQuery(query)
Communities.groups(pagingQuery, success: { result in
    print("Groups: \(result.groups)")
}, failure: { error in
    print("Failed to get list of groups: \(error)")
})
1
2
3
4
5
6
7
8
var query = GroupsQuery.All();
var pagingQuery = new PagingQuery<GroupsQuery>(query);

Communities.GetGroups(pagingQuery, (result) => {
    Debug.Log("Groups: " + result.Entries);
}, (error) => {
    Debug.Log("Failed to get list of groups, error: " + error);
});
1
Coming soon...
1
Coming soon...

This method uses the PagingQuery concept that is used across our SDK. Read more about this.

You can also see all the groups created by your company or your users in the dashboard. The list of group includes group Id, name, description, creation date, number of group members, number of group followers and certain actions that you can take as follows:

  • Post to feed: You can post an activity to a specific group from the dashboard, just like you post to a topic.
  • Edit group details like group name, description, icon, permissions and properties
  • Delete group

Find Groups

You can also search groups by a query. Method returns all groups that contains the provided query as a substring in ID or Title. It is also case-insensitive. Additionally you can search gruoups by:
- All groups that are discoverable
- Groups a user is member of
- Groups a user is following

1
2
3
4
5
6
7
8
9
val searchString = "cat"
val query = GroupsQuery.find(searchString)
val pagingQuery = PagingQuery(query)
Communities.getGroups(pagingQuery, { result: PagingResult<Group> ->
    val groups = result.entries
    print("Groups contains $searchString: $groups")
}, { error: GetSocialError ->
    print("Failed to get list of groups: $error")
})
1
2
3
4
5
6
7
8
let searchString = "cat"
let query = GroupsQuery.find(searchString)
let pagingQuery = GroupsPagingQuery(query)
Communities.groups(pagingQuery, success: { result in
    print("Groups containing \(searchString): \(result.groups)")
}, failure: { error in
    print("Failed to get list of groups: \(error)")
})
1
2
3
4
5
6
7
8
var query = GroupsQuery.Find("cats");
var pagingQuery = new PagingQuery<GroupsQuery>(query);

Communities.GetGroups(pagingQuery, (result) => {
    Debug.Log("Groups including `cats`: " + result.Entries);
}, (error) => {
    Debug.Log("Failed to search for groups, error: " + error);
});
1
Coming soon...
1
Coming soon...

This method uses the PagingQuery concept that is used across our SDK. Read more about this.

Get Groups Count

Use the same query as you’re using to Get or Find groups.

1
2
3
4
5
6
7
val searchString = "cat"
val query = GroupsQuery.find(searchString)
Communities.getGroupsCount(query, { result: Int ->
    print("Groups count contains $searchString: $result")
}, { error: GetSocialError ->
    print("Failed to get number of groups: $error")
})
1
2
3
4
5
6
7
let searchString = "cat"
let query = GroupsQuery.find(searchString)
Communities.groupsCount(query, success: { groupsCount in
    print("Groups count containing \(searchString): \(groupsCount)")
}, failure: { error in
    print("Failed to get number of groups: \(error)")
})
1
2
3
4
5
6
7
var query = GroupsQuery.Find("cats");

Communities.GetGroupsCount(query, (result) => {
    Debug.Log("Number of groups including `cats`: " + result);
}, (error) => {
    Debug.Log("Failed to get number of groups, error: " + error);
});
1
Coming soon...
1
Coming soon...

Get Group By ID

If you have just an ID of Group, you can get the Group object:

1
2
3
4
5
6
7
val groupId = "group-id"

Communities.getGroup(groupId, { group ->
    print("Group with id $groupId: $group")
}, { error ->
    print("Failed to get a group: $error")
})
1
2
3
4
5
6
let groupId = "group-id"
Communities.group(groupId, success: { group in
    print("Group with id '\(groupId): \(group)")
}, failure: { error in
    print("Failed to get group: \(error)")
})
1
2
3
4
5
6
7
var groupId = "group-id";

Communities.GetGroup(groupId, (result) => {
    Debug.Log("Group: " + result);
}, (error) => {
    Debug.Log("Failed to get group, error: " + error);
});
1
Coming soon...
1
Coming soon...

Work With Group Object

Learn what can you do with group object in Android and iOS.

Manage Group Members

Groups has 3 different kind of members:

  • Owner: the user that created the group and can update the group details and manage other members.
  • Admin: a member that has been promoted to admin by the owner an can also perform the same actions than the owner.
  • Regular member: a user that has access to the Group feed and might be able to post or interact according to the Group permissions.

Add or Invite Users

Owner and Admins can invite users to join the group with an invitation sent via Notifications or users can be added directly, depending on your implementation.

To add a user:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
val groupId = // group id
val userIds = // list of user ids
val query = AddGroupMembersQuery.create(groupId, userIds)
        .withMemberStatus(MemberStatus.MEMBER)

Communities.addGroupMembers(query, { result: MutableList<GroupMember> ->  
    print("Users added to group")
}, { error ->  
    print("Failed to add users to group, error: $error")
})
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
let groupId = // group id
let userIds = // list of user ids
let query = AddGroupMembersQuery(groupId: groupId, userIdList: userIds)
                .withMemberStatus(.member)

Communities.addGroupMembers(query, success: { members in
    print("Users added to group")
}, failure: { error in
    print("Failed to add users to group, error: \(error)")
})
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
var groupId = // group id
var userIds = // list of user ids
var query = new AddGroupMembersQuery(groupId, userIds)
                .WithMemberStatus(MemberStatus.Member);

Communities.AddGroupMembers(query, (result) => {
    Debug.Log("Users added to group");
}, (error) => {
    Debug.Log("Failed to add users to group, error: " + error);
});
1
Coming soon...
1
Coming soon...

To invite a user:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
val groupId = // group id
val userIds = // list of user ids

val query = AddGroupMembersQuery.create(groupId, userIds)
        .withMemberStatus(MemberStatus.INVITATION_PENDING)
Communities.addGroupMembers(query, { result: MutableList<GroupMember> ->
    print("Users invited to group")
}, { error ->
    print("Failed to invite users to group, error: $error")
})
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
let groupId = // group id
let userIds = // list of user ids

let query = AddGroupMembersQuery(groupId: groupId, userIdList: userIds)
                .withMemberStatus(.invitationPending)
Communities.addGroupMembers(query, success: { members _ in
    print("Users invited to group")
}, failure: { error in
    print("Failed to invite users to group, error: \(error)")
})
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
var groupId = // group id
var userIds = // list of user ids
var query = new AddGroupMembersQuery(groupId, userIds)
                .WithMemberStatus(MemberStatus.InvitationPending);

Communities.AddGroupMembers(query, (result) => {
    Debug.Log("Users invited to group");
}, (error) => {
    Debug.Log("Failed to invite users to group, error: " + error);
});
1
Coming soon...
1
Coming soon...

To invite an admin:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
val groupId = // group id
val userIds = // list of user ids

val query = AddGroupMembersQuery.create(groupId, userIds)
        .withMemberStatus(MemberStatus.INVITATION_PENDING)
        .withRole(Role.ADMIN)
Communities.addGroupMembers(query, { result: MutableList<GroupMember> ->
    print("Users invited to group")
}, { error ->
    print("Failed to invite users to group, error: $error")
})
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
let groupId = // group id
let userIds = // list of user ids

let query = AddGroupMembersQuery(groupId: groupId, userIdList: userIds)
                .withMemberStatus(.invitationPending)
                .withRole(.admin)
Communities.addGroupMembers(query, success: { members in
    print("Users invited to group")
}, failure: { error in
    print("Failed to invite users to group, error: \(error)")
})
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
var groupId = // group id
var userIds = // list of user ids
var query = new AddGroupMembersQuery(groupId, userIds)
                .WithMemberStatus(MemberStatus.InvitationPending)
                .WithMemberRole(MemberRole.Admin);

Communities.AddGroupMembers(query, (result) => {
    Debug.Log("Users invited to group");
}, (error) => {
    Debug.Log("Failed to invite users to group, error: " + error);
});
1
Coming soon...
1
Coming soon...

Join Groups or Accept an Invitation

Users can join groups directly. For public groups they will become a member right away, but for private ones, they will need to wait for the approval.

To join a group, either public or private:

1
2
3
4
5
6
7
val groupId = // group id
val query = JoinGroupQuery(groupId)
Communities.joinGroup(query, { member: GroupMember ->
    print("Joined to group")
}, { error ->
    print("Failed to join to group, error: $error")
})
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
let groupId = // group id
let query = JoinGroupQuery.init(groupId: groupId)
Communities.joinGroup(query, success: { member in 
    print("Joined to group")
}, failure: { error in
    print("Failed to join to group, error: \(error)")
}

```c# tab="Unity"
var groupId = // group id
var query = new JoinGroupQuery(groupId);
Communities.JoinGroup(query, success: (member) => {
    Debug.Log("Joined to group");
}, (error) => {
    Debug.Log("Failed to join to group, error: " + error);
});
1
Coming soon...
1
Coming soon...

If the group is private a request to join Notification will be sent automatically to the Owner and Admins and one of them will need to approve it. Once the request is approved, the User will get a Notification.

To approve a request to join from a user (only possible if the requesting user is a Group owner or admin):

1
2
3
4
5
6
7
8
9
val groupId = // group id
val userIds = // users to approve
val query = UpdateGroupMembersQuery.create(groupId, userIds)
    .withMemberStatus(MemberStatus.MEMBER)
Communities.updateGroupMembers(query, { members ->
    print("Users approved")
}, {  error ->
    print("Failed to approve users, error: $error")
})
1
2
3
4
5
6
7
8
9
let groupId = // group id
let userIds = // users to approve
let query = UpdateGroupMembersQuery.init(groupId: groupId, userIdList: userIds)
                .withMemberStatus(.member)
Communities.updateGroupMembers(query, success: { members in
    print("Users approved")
}, failure: {  error in
    print("Failed to approve users, error: \(error)")
})
1
2
3
4
5
6
7
8
9
var groupId = // group id
var userIds = // users to approve
var query = new UpdateGroupMembersQuery(groupId, userIds)
                .WithMemberStatus(MemberStatus.Member);
Communities.UpdateGroupMembers(query, (members) => {
    Debug.Log("Users approved");
}, (error) => {
    Debug.Log("Failed to approve users, error: " + error);
});
1
Coming soon...
1
Coming soon...

Alternatively, if the user was invited to join the group, then he needs to accept the invitation using the invitation token received in the Invitation.

1
2
3
4
5
6
7
8
9
val groupId = // group id
val invitationToken = // group invitation token
val query = JoinGroupQuery(groupId)
        .withInvitationToken(invitationToken)
Communities.joinGroup(query, { member: GroupMember ->
    print("User accepted invite")
}, { error ->
    print("Failed to accept invite, error: $error")
})
1
2
3
4
5
6
7
8
9
let groupId = // group id
let invitationToken = // group invitation token
let query = JoinGroupQuery.init(groupId: groupId)
                .withInvitationToken(invitationToken)
Communities.joinGroup(query, success: { member in
    print("User accepted invite")
}, failure: { error in 
    print("Failed to accept invite, error: \(error)")
})
1
2
3
4
5
6
7
8
9
var groupId = // group id
var invitationToken = // group invitation token
var query = new JoinGroupQuery(groupId)
                .WithInvitationToken(invitationToken);
Communities.JoinGroup(query, success: (member) => {
    Debug.Log("User accepted invite");
}, (error) => {
    Debug.Log("Failed to accept invite, error: " + error);
});
1
Coming soon...
1
Coming soon...

Approve Join Request

If the Owner or Admin receives a request to join Notification from a user, it can be approved like this:

1
2
3
4
5
6
7
8
9
val groupId = // group id
val userIds = // users to approve
val query = UpdateGroupMembersQuery.create(groupId, userIds)
    .withMemberStatus(MemberStatus.MEMBER)
Communities.updateGroupMembers(query, { members ->
    print("Users approved")
}, {  error ->
    print("Failed to approve users, error: $error")
})
1
2
3
4
5
6
7
8
9
let groupId = // group id
let userIds = // users to approve
let query = UpdateGroupMembersQuery.init(groupId: groupId, userIdList: userIds)
                .withMemberStatus(.member)
Communities.updateGroupMembers(query, success: { members in
    print("Users approved")
}, failure: {  error in
    print("Failed to approve users, error: \(error)")
})
1
2
3
4
5
6
7
8
9
var groupId = // group id
var userIds = // users to approve
var query = new UpdateGroupMembersQuery(groupId, userIds)
                .WithMemberStatus(MemberStatus.Member);
Communities.UpdateGroupMembers(query, (members) => {
    Debug.Log("Users approved");
}, (error) => {
    Debug.Log("Failed to approve users, error: " + error);
});
1
Coming soon...
1
Coming soon...

Removing Group Members

The Owner and Admins can remove any member, however regular members can only remove themselves.

To remove a member:

1
2
3
4
5
6
7
8
val groupId = // group id
val userIds = // user ids to removed from group
val query = RemoveGroupMembersQuery.create(groupId, userIds)
Communities.removeGroupMembers(query, {
    print("Removed user from group")
}, { error ->
    print("Failed to remove users from group, error: $error")
})
1
2
3
4
5
6
7
8
let groupId = // group id
let userIds = // user ids to removed from group
let query = RemoveGroupMembersQuery.users(userIds, from: groupId)
Communities.removeGroupMembers(query, success: {
    print("Removed user from group")
}, failure: { error in 
    print("Failed to remove users from group, error: \(error)")
}
1
2
3
4
5
6
7
8
var groupId = // group id
var userIds = // user ids to removed from group
var query = new RemoveGroupMembersQuery(groupId, userIds);
Communities.RemoveGroupMembers(query, () => {
    Debug.Log("Removed user from group");
}, (error) => {
    Debug.Log("Failed to remove users from group, error: " + error);
});
1
Coming soon...
1
Coming soon...

Get Group Members

It is possible to get the list of members of a specific group. It can be filtered by status or role. Regular members can only see approved members, however the Owner or Admins can also see invitations and pending-approval join request.

To get the list of members:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
val groupId = // group id
val query = MembersQuery.ofGroup(groupId)
// with a specific role, e.g. admins
// query = query.withRole(Role.ADMIN)
// with a specific status, like all pending approvals
// query = query.withMemberStatus(MemberStatus.APPROVAL_PENDING)
val pagingQuery = PagingQuery(query)
Communities.getGroupMembers(pagingQuery, { result ->
    print("Members of group: $result.entries")
}, { error ->
    print("Failed to get group members, error: $error")
})
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
let groupId = // group id
let query = MembersQuery.ofGroup(groupId)
// with a specific role, e.g. admins
// query = query.withRole(.admin)
// with a specific status, like all pending approvals
// query = query.withStatus(.approvalPending)
let pagingQuery = MembersPagingQuery(query)
Communities.membersOfGroup(pagingQuery, success: { result in
    print("Members of group: \(result.entries)")
}, failure: { error in
    print("Failed to get group members, error: \(error)")
})
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
var groupId = // group id
var query = MembersQuery.OfGroup(groupId);
// with a specific role, e.g. admins
// query = query.WithRole(MemberRole.Admin)
// with a specific status, like all pending approvals
// query = query.withStatus(MemberStatus.ApprovalPending)
var pagingQuery = new PagingQuery<MembersQuery>(query);
Communities.GetGroupMembers(pagingQuery, (result) => {
    Debug.Log("Members of group: " + result.Entries);
}, (error) => {
    Debug.Log("Failed to get group members, error: " + error);
});
1
Coming soon...
1
Coming soon...

Check Group Members

You can also check if specific users are members of a group:

1
2
3
4
5
6
7
val groupId = // group id
val userIds = // user ids
Communities.areGroupMembers(groupId, userIds, { result ->
    print("Members of group: $result")
}, { error ->
    print("Failed to check group members, error: $error")
})
1
2
3
4
5
6
7
let groupId = // group id
let userIds = // user ids
Communities.areGroupMembers(groupId, userIdList: userIds, success: { result in
    print("Members of group: \(result)")
}, failure: { error in
    print("Failed to check group members, error: \(error)")
})
1
2
3
4
5
6
7
var groupId = // group id
var userIds = // user ids
Communities.AreGroupMembers(groupId, userIdList: userIds, (result) => {
    Debug.Log("Members of group: " + result);
}, (error) => {
    Debug.Log("Failed to check group members, error: " + error);
});
1
Coming soon...
1
Coming soon...

Follow

Group members become also group followers automatically as soon as they join and they will start seeing content from the Group feed in their timeline. However if members want to stop seeing Group content they can unfollow the group while keeping their member status. They can follow back at any time.

To follow groups use (only available for group members):

1
2
3
4
5
Communities.follow(FollowQuery.groups("dogs", "cats", "daily-challenges"), { groupsFollowing ->
    print("Successfully followed the groups. Now you follow $groupsFollowing groups!")
}, { error ->
    print("Failed to follow groups: $error")
})
1
2
3
4
5
Communities.follow(FollowQuery.groups(["dogs", "cats", "daily-challenges"]), success: { groupsFollowing in
    print("Successfully followed the groups. Now you follow \(groupsFollowing) groups!")
}, failure: { error in
    print("Failed to follow groups: \(error)")
})
1
2
3
4
5
Communities.Follow(FollowQuery.Groups("dogs", "cats", "daily-challenges"), (groupsFollowing) => {
    Debug.Log("Successfully followed the groups. Number of followed groups: " + groupsFollowing);
}, (error) => {
    Debug.Log("Failed to follow groups, error " + error);
});
1
Coming soon...
1
Coming soon...

Unfollow

Unfollow works in the same way, as Follow, just use method unfollow:

1
2
3
4
5
Communities.unfollow(FollowQuery.groups("dogs", "cats", "daily-challenges"), { groupsFollowing ->
    print("Successully unfollowed the groups. Now you follow $groupsFollowing groups!")
}, { error ->
    print("Failed to follow groups: $error")
})
1
2
3
4
5
Communities.unfollow(FollowQuery.groups(["dogs", "cats", "daily-challenges"]), success: { groupsFollowing in
    print("Successully unfollowed the groups. Now you follow \(groupsFollowing) groups!")
}, failure: { error in
    print("Failed to follow groups: \(error)")
})
1
2
3
4
5
Communities.Unfollow(FollowQuery.Groups("dogs", "cats", "daily-challenges"), (groupsFollowing) => {
    Debug.Log("Successfully unfollowed the groups. Number of followed groups: " + groupsFollowing);
}, (error) => {
    Debug.Log("Failed to unfollow groups, error " + error);
});
1
Coming soon...
1
Coming soon...

Is Following

To check if a certain user is following groups, use:

1
2
3
4
5
6
Communities.isFollowing(UserId.currentUser(), FollowQuery.groups("cats", "dogs"), { isFollowing ->
    print("Current user is following group 'cats': ${isFollowing["cats"]}")
    print("Current user is following group 'dogs': ${isFollowing["dogs"]}")
}, { error: GetSocialError ->
    print("Failed to get followers of group: $error")
})
1
2
3
4
5
6
Communities.isFollowing(UserId.currentUser(), query: FollowQuery.groups(["cats", "dogs"]), success: { isFollowing in
    print("Current user is following group 'cats': \(isFollowing["cats"])")
    print("Current user is following group 'dogs': \(isFollowing["dogs"])")
}, failure: { error in
    print("Failed to check followers of groups: \(error)")
})
1
2
3
4
5
6
Communities.IsFollowing(UserId.CurrentUser(), FollowQuery.Groups("cats", "dogs"), (result) => {
    Debug.Log("Current user is following group 'cats': " + result["cats"]);
    Debug.Log("Current user is following group 'dogs': " + result["dogs"]);
}, (error) => {
    Debug.Log("Failed to check followers of groups, error: " + error);
});
1
Coming soon...
1
Coming soon...

First parameter is a user ID. We’re checking if current user is following some groups. The result is a map of String -> Boolean, where key is the id of the group passed to FollowQuery and value is true, is user is following this group or false otherwise.

Unexisting groups won’t be included in the result map.

Get Followers

To get followers of a group:

1
2
3
4
5
6
7
8
val followersQuery = FollowersQuery.ofGroup("cats")
val pagingQuery = PagingQuery(followersQuery).withLimit(25)
Communities.getFollowers(pagingQuery, { result: PagingResult<User> ->
    val followersOfCatsGroup = result.entries
    print("Followers of group 'cats': $followersOfCatsGroup")
}, { error: GetSocialError ->
    print("Failed to get followers of the group: $error")
})
1
2
3
4
5
6
7
8
9
let followersQuery = FollowersQuery.ofGroup("cats")
let pagingQuery = FollowersPagingQuery.init(followersQuery)
pagingQuery.limit = 25

Communities.followers(pagingQuery, success: { result in
    print("Followers of group 'cats': \(result.followers)")
}, failure: { error in
    print("Failed to get followers of group: \(error)")
})
1
2
3
4
5
6
7
var followersQuery = FollowersQuery.OfGroup("cats");
var pagingQuery = new PagingQuery<FollowersQuery>(followersQuery);
Communities.GetFollowers(pagingQuery, (result) => {
    Debug.Log("Followers of group 'cats': " + result.Entries);
}, (error) => {
    Debug.Log("Failed to get followers of group: " + error);
});
1
Coming soon...
1
Coming soon...

This method uses the PagingQuery concept that is used across our SDK. Read more about this.

Followers Count

To get the followers count of a group:

1
2
3
4
5
6
val groupsFollowers = FollowersQuery.ofGroup("level1")
Communities.getFollowersCount(groupsFollowers, { followersCount: Int ->
    print("Followers count of group 'level1': $followersCount")
}, { error: GetSocialError ->
    print("Failed to get followers of group: $error")
})
1
2
3
4
5
6
let groupFollowers = FollowersQuery.ofGroup("level1")
Communities.followersCount(groupFollowers, success: { followersCount in
    print("Followers count of group 'level1': \(followersCount)")
}, failure: { error in
    print("Failed to get followers count of group: \(error)")
})
1
2
3
4
5
6
var groupFollowers = FollowersQuery.OfGroup("cats");
Communities.GetFollowersCount(groupFollowers, (result) => {
    Debug.Log("Followers count of group 'cats': " + result);
}, (error) => {
    Debug.Log("Failed to get followers count of group: " + error);
});
1
Coming soon...
1
Coming soon...

Get Following Groups

You can also get all the groups that are followed by a certain user:

1
2
3
4
5
6
7
8
val query = GroupsQuery.followedBy(UserId.currentUser())
val pagingQuery = PagingQuery(query)
Communities.getGroups(pagingQuery, { result: PagingResult<Group> ->
    val groups = result.entries
    print("Groups followed by current user: $groups")
}, { error: GetSocialError ->
    print("Failed to get list of groups: $error")
})
1
2
3
4
5
6
7
let query = GroupsQuery.followedBy(UserId.currentUser())
let pagingQuery = GroupsPagingQuery(query)
Communities.groups(pagingQuery, success: { result in
    print("Groups followed by current user: \(result.groups)")
}, failure: { error in
    print("Failed to get list of groups: \(error)")
})
1
2
3
4
5
6
7
var query = GroupsQuery.FollowedBy(UserId.CurrentUser());
var pagingQuery = new PagingQuery<GroupsQuery(query);
Communities.GetGroups(pagingQuery, (result) => {
    Debug.Log("Groups followed by current user: " + result.Entries);
}, (error) => {
    Debug.Log("Failed to get list of groups: " + error);
});
1
Coming soon...
1
Coming soon...

Give us your feedback! Was this article helpful?

😀 🙁