social.plus SDK provides comprehensive community membership management enabling users to join and leave communities with support for different community types, approval workflows, and moderation capabilities. Build seamless membership experiences with automatic joining, approval requests, and administrative controls.

Join Communities

Add users to communities with immediate or approval-based joining

Join Request Management

Handle pending requests with user and moderator workflows

Leave Communities

Remove users from communities and revoke access privileges

Community Access Control

Manage different community types and membership requirements
Users automatically become members when joining a community and lose access when leaving. Private communities may require invitations or approval, creating join requests that moderators can approve or reject.

Community Types and Access Control

Understanding community types is essential for implementing proper membership workflows:
Community TypeVisibilityJoin BehaviorUse Case
Public (No Approval)DiscoverableImmediate membershipOpen communities, public discussions
Public (Requires Approval)DiscoverablePending approval requiredModerated public communities
Private & VisibleDiscoverable, content hiddenApproval requiredSemi-private groups with controlled access
Private & HiddenNot discoverableInvitation/approval onlyExclusive communities, private groups

Network-Level Membership Settings

Your network can be configured with different membership acceptance modes:
  • Automatic Membership (default): Users become members immediately when added
  • Invitation Acceptance: Users receive invitations and must explicitly accept before joining

Join Community

The join() method adds the active user as a member of the specified community, enabling access to community content and participation privileges. The joining process varies based on community type and approval requirements.

Parameters

ParameterTypeRequiredDescription
communityIdStringYesUnique identifier of the community to join
var community: AmityCommunity! // Fetched Community

Task { @MainActor in
    do {
        let result = try await community.join()
        
        switch result {
        case .success:
            // Community does not require join approval & is joined immediately
            // ...
            break
        case .pending(let joinRequest):
            // Community requires join approval & joinRequest status is now in pending state
            let joinRequestStatus = joinRequest.status
        }
    } catch let error {
        // Handle error
    }
}

Join Request Management

For communities requiring approval, join requests provide a workflow for users to request membership and moderators to control access.

User Operations

Check Join Request Status

Users can monitor the status of their submitted join requests:
var community: AmityCommunity! // Fetched Community

Task { @MainActor in
    do {
        let joinRequest: AmityJoinRequest = try await community.getMyJoinRequest()
        
    } catch let error {
        // Handle error
    }
    
}

Cancel Join Request

Users can cancel pending join requests:
var joinRequest: AmityJoinRequest! // Retrieved join request

func cancelJoinRequest() {
    Task { @MainActor in
        do {
            try await joinRequest.cancel()
            print("Join request cancelled successfully")
            updateUIForCancelledRequest()
        } catch let error {
            print("Error cancelling join request: \(error)")
        }
    }
}

Moderator Operations

Get Pending Join Requests

Moderators can retrieve all pending join requests for their communities:
var token: AmityNotificationToken?
var community: AmityCommunity! // Fetched Community

func getPendingJoinRequests() {
    token = community.getJoinRequests(status: .pending).observe { liveCollection, _, error in
        if let error = error {
            print("Error fetching join requests: \(error)")
            return
        }
        
        let joinRequests: [AmityJoinRequest] = liveCollection.snapshots
        
        // Update UI with pending requests
        updateJoinRequestsList(joinRequests)
        
        print("Found \(joinRequests.count) pending join requests")
    }
}

Approve/Reject Join Requests

Moderators can approve or reject join requests:
func approveJoinRequest(_ joinRequest: AmityJoinRequest) {
    Task { @MainActor in
        do {
            try await joinRequest.approve()
            print("Join request approved successfully")
            refreshJoinRequestsList()
        } catch let error {
            print("Error approving join request: \(error)")
        }
    }
}

func rejectJoinRequest(_ joinRequest: AmityJoinRequest) {
    Task { @MainActor in
        do {
            try await joinRequest.reject()
            print("Join request rejected successfully")
            refreshJoinRequestsList()
        } catch let error {
            print("Error rejecting join request: \(error)")
        }
    }
}

Leave Community

The leaveCommunity() method removes the active user from a community, revoking access to community content and participation privileges.

Parameters

ParameterTypeRequiredDescription
communityIdStringYesUnique identifier of the community to leave
Leaving a community immediately removes access to all community content, posts, and conversations. This action cannot be undone without rejoining.
do {
    let success = try await communityRepository.leaveCommunity(withId: "community-id")
} catch {
    // Handle error here
}

Best Practices

User Experience: Always provide clear feedback about membership status changes and explain any waiting periods for approval-based communities.

UI/UX Guidelines

  1. Clear Status Indicators: Show membership status and pending request states
  2. Action Feedback: Provide immediate feedback for join/leave actions
  3. Error Handling: Display user-friendly error messages with next steps
  4. Confirmation Dialogs: Confirm leave actions to prevent accidental departures

Implementation Patterns

  1. Real-time Updates: Use Live Objects to reflect membership changes immediately
  2. Optimistic UI: Update UI immediately, rollback on error
  3. Request Management: Implement proper join request workflows for moderators
  4. Navigation Logic: Handle post-leave navigation appropriately