Communities

Create Repository

Community Description

Name

Data Type

Description

Attributes

communityId

String

ID of the community

channelId

String

ID of the channel

userId

String

ID of the user who created the community

displayName

String

Community name for displaying

avatarFileId

String

ID of the avatar file

description

String

Description of the community

isOfficial

Boolean

Is this community official?

isPublic

Boolean

Is this community public?

onlyAdminCanPost

Boolean

Can post by admin only?

tags

AmityTags

List of tags used for searching

metadata

Map<String,dynamic>

Additional properties to support custom fields

postsCount

Integer

Number of posts in community

membersCount

Integer

Number of members in community

isJoined

Boolean

Is this community joined?

categoryIds

List<String>

ID of categories

isDeleted

Boolean

Is this community deleted?

Default: false

createdAt

DateTime

Date/time when the community was created

updatedAt

DateTime

Date/time when a community is updated or deleted

Community Query

There are methods to obtain communities that only match specific criteria:

  • the withKeyword parameter let you filter communities based on the community displayName

  • the sortBy parameters let you filter communities based on the order that the communities were created or based on alphabetical order

  • the filter parameter let you filter communities based on the logged-in user membership status

  • the categoryId parameters let you filter communities based on community categories

Create Community

When creating a new community, first instantiates the AmityCommunityRepository, a class that contains all community-related methods. Then call createCommunity() to obtain the RxJava and observe it in order to obtain the final community model. If you prefer to create a community with an avatar you can first upload an image with AmityFileRepository and then pass the obtained AmityImageto createCommunityAPI.

Join Community

The joinCommunity() method will add the active user as a member of the channel.

Leave Community

The LeaveCommunity() method will add the active user as a member of the channel.

Get Community

In the case where you only want to fetch community data without joining, you can use the getCommunity(:id) function.

In order to get live update from any changes or bind with StreamBuilder widget, you can alternatively use AmityCommunity.listen

Community Repository provides a way to fetch trending and recommended communities.

  • Trending communities

    This is a list of communities with the highest number of members. It can be a combination of communities where the user may or may not be part of.

  • Recommended communities

    This is a list of communities with the highest member count. The communities in the list are those that the user is not part of.

Note: You can fetch a maximum of 15 items from the trending and recommendation communities at once.

Update Community

SDK provides the builder class CommunityUpdaterBuilder which allows you to set properties that you want to update. Then you can use updateCommunity method in AmityCommunityRepository to update the community.

Delete Community

You can delete a community by calling the deleteCommunity method. It accepts the community ID as the parameter.

Community Membership

Query Members

You can get a list of community members by calling the following function.

Add Members

Remove Members

Role and Permission

AmityCommunityModeration class provides a way to moderate the community by banning or unbanning users. banMembers(...) method accepts an array of user ids to ban and unbanMembers(...) accepts an array of user ids to unban.

You can also add/remove roles using addRole(...) and removeRole(...) method. These functions accept an array of strings as an argument that contains the roles that you want to add or remove from a specific user.

Add Role

Remove Role

Ban Member

Unban Member

Community Categories

When communities are put into a category, you will be able to sort and filter each of the communities in that category.

Currently, categories will only be creatable and updatable from the Amity Social Cloud Console.

Category Query

This method provides the ability to obtain all the categories.

The default sortBy is NAME so you can skip .sortBy in the builder

Last updated