User
Identity
Amity SDK's do not store or manage any user data. This means that you do not have to import or migrate existing user profiles into the system, user management should be handled by your application code. Instead, every user is simply represented by a unique userID
, which can be any string that uniquely identifies the user and is immutable throughout its lifetime.
A database primary key would make an ideal
userID
. Conversely, something like username or emails is not recommended as those values may change overtime.
If you wish to assign additional permissions for a user, for example moderation privileges or different sending limits, you can provide an array of roles to assign to this user. Roles are defined in the admin panel and can be tied to an unlimited number of users. Once again, Amity does not store or manage any user data, which means you do not have to import or migrate existing users into the system. It also means that Amity cannot provide user management functionalities like lists of users, or limit actions of certain users (e.g. user permissions). Instead, these functionalities should be handled by the rest of your application's capabilities and your server.
Descriptions of Users
Name | Data Type | Description | Attributes |
|
| The id of this user | |
|
| A list of user's roles | |
|
| The display name of the user | |
|
| The number of users that have flagged this user | |
|
| The metadata of the user | |
|
| A hash for checking internally if this user was flagged by the user | |
|
| The date/time the user was created at | |
|
| The date/time the user was updated at |
Though the SDK does not store and should not be responsible for the handling User profile data for your application; We do provide tools to make some surface-level queries and searches for existing user accounts. With the help of our EkoUserRepository
class, you would be able to list all the users, search for list of users whose display name matches your search query and get EkoUser
object from user id.
User Details
Each EkoUser
consists of a userId
and displayName
. The userId
is immutable once the account is created, however the displayName
can be updated at all times.
User repository
To get EkoUserRepository
instance
Query User
EkoUserRepository
provides a convenient method getAllUsers()
to fetch all users. You can observe for changes in collection, similar to message or channel. The method accepts EkoUserSortOption
as an optional parameter. The list can be sorted by displayName, firstCreated or lastCreated.
EkoUserRepository
provides searchUserByDisplayName()
method which allows you to query for users using their display name. It provides you with a LiveCollection of EkoUser
whose display name matches with your search query. EkoUserSortOption
is an optional parameter.
The code above will provide you with the list of users which matches with display name "John".
EkoUserSortOption
has 3 enums type 1. EkoUserSortOption.DISPLAYNAME
Sort by displayName 2. EkoUserSortOption.FIRST_CREATED
Sort by firstCreated 3. EkoUserSortOption.LAST_CREATED
Sort by lastCreated
Last updated