Communities
Create Repository
Community Description
Name | Data Type | Description | Attributes |
|
| ID of the community | |
|
| ID of the channel | |
|
| ID of the user who created the community | |
|
| Community name for displaying | |
|
| ID of the avatar file | |
|
| Description of the community | |
|
| Is this community official? | |
|
| Is this community public? | |
|
| Can post by admin only? | |
|
| List of tags used for searching | |
|
| Additional properties to support custom fields | |
|
| Number of posts in community | |
|
| Number of members in community | |
|
| Is this community joined? | |
|
| ID of categories | |
|
| Is this community deleted? | Default: |
|
| Date/time when the community was created | |
|
| 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 communitydisplayName
the
sortBy
parameters let you filter communities based on the order that the communities were created or based on alphabetical orderthe
filter
parameter let you filter communities based on the logged-in user membership statusthe
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 AmityImage
to createCommunity
API.
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
Trending and Recommended Communities
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