Links

Flag / Unflag User

Flag / Unflag User feature is an essential tool for maintaining a safe and engaging chat community. With Amity Social Cloud, you can use the flag and unflag user feature to allow moderators and administrators to monitor any inappropriate behavior within a chat channel.
In this section, we will discuss how to use the flag and unflag user feature of Amity Chat SDK to maintain a safe and engaging chat community.
To flag / unflag users on iOS, Android and Flutter SDK, create an instance of UserFlagger first:
iOS
Android
Flutter
let userRepository: AmityUserRepository = AmityUserRepository(client: client)
let userToBeFlaggedObject: AmityObject<AmityUser> = userRepository.user(forId: "badUser")
guard let userToBeFlagged: AmityUser = userToBeFlaggedObject.object else { return }
let userFlagger = AmityUserFlagger(client: client, userId: IdOfuserToBeFlagged)
The UserFlagger lets you flag and unflag a user. It also exposes an asynchronous way to check whether the current logged-in user has already flagged the given user or not.

Flag a User

To flag a user, call the following method:
iOS
Android
JavaScript
TypeScript
Flutter
userRepo.flag({ userId: 'user123' })

Unflag a User

To unflag a user, call the following method:
iOS
Android
JavaScript
TypeScript
Flutter
userRepo.unflag({ userId: 'user123' })

Check Flagged By User

To check whether a user has been flagged by the current user:
iOS
Android
JavaScript
TypeScript
Flutter
userRepo.flag({ userId: 'user123' })
.then(() => {})
.catch(() => {})