Communities
Build and nurture vibrant communities where users can exchange and connect

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 comment
displayName
String
Community name for displaying
avatar
Object
Avatar object
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
Array.<String>
List of tags used for searching
metadata
Object
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
Array.<String>
ID of categories
isDeleted
Boolean
Is this community deleted?
Default: false
createdAt
String($date-time)
Date/time when the community was created
updatedAt
String($date-time)
Date/time when a community is updated or deleted
hasFlaggedPost
Boolean
Flag for checking internally if post inside community is reported or not
Default: false

Create Community

First, you will need to create the community by using AmityCommunityCreationDataBuilder instance. The mandatory property is displayName. You can set other properties as per your necessities.

Join Community

Leave Community

Get Community

In the case where you only want to fetch a community's data without joining, you can use the getCommunity(withId:) method:

Community Query

There are methods to obtain communities that will only meet certain specific criteria:
  • the keyword parameter allows you to filter communities based on the community displayName
  • 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
  • the sortBy parameters let you filter communities based on the order that the communities were created or based on alphabetical order
  • the includeDeleted parameters let you specify if you want to include deleted communities in your query
If you want to fetch all communities, you can pass the keyword as nil.
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.

Update Community

SDK provides the builder class AmityCommunityUpdateDataBuilder which allows you to set properties that you want to update. Then you can use updateCommunity method in AmityCommunityRepository to update the community.
You can also delete the community by using deleteCommunity(_:) method.
Note. By default, only the community's original creator or administrators can update/delete the community.

Community Membership

You can get a list of community members through AmityCommunityParticipation class. It exposes getMembers method which accepts membershipOptions and sortBy parameters.
The membershipOptions parameter can have the following filters:
  • .member - filters all unbanned members
  • .ban - filters all banned members
Passing an empty option set for membershipOptions parameter will default to .member. This means that the result for both sample code below is the same.
Same class provides addMembers(_:) and removeMembers(_:) which can be used to add or remove users from the community.

Community Moderation

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 addRoles(_:) and removeRoles(_:) method. These functions accept an array of string as an argument that contains the roles that you want to add or remove from a specific user.
addRoles(_:) and removeRoles(_:) do not create new roles but assign and remove existing roles from given users. You can add or remove default roles as well as custom roles.

Community Categories

The AmityCommunityRepository will also be able to manage community categories. When communities are put into a category, you will be able to sort and filter each of the communities in that category. You can access the categories for any communities through categories property in each AmityCommunity object.
Note: Categories can only be created and updated from Amity Social Cloud Console.

Get Categories

Post review

Allow your users to create posts in a community, you can also create another layer of moderation on top that allows community owners the ability to decide whether the post should be reflected on the feed, or not.

Post count with FeedType

AmityCommunity model allows user to get post count by feed type .
AmityCommunity model allows user to get status of isPostReviewEnabled

Permission

If you want to check the permissions of a post in review for a community, you can use this enum.
AmityPermission.reviewCommunityPost by following this

Post Approval

Create Community

If you want to create a community and need to review post before they're added to your community feed, you can call the following:
Note. The isPostReviewEnabled value is published by default. if you do not call this function, a post of member will be shown on community feed immediately without reviewing.

Update Community

If you want to update a community and change the status of isPostReviewEnable, you can call the following:

Delete Community

You can delete a community by calling the deleteCommunity method. It accepts the community ID as the parameter.
Last modified 1mo ago