Initiate User
To start using the LikeMinds Chat and enable personalized experiences for your users, you need to initiate them within the system. This process associates a user in your application with a user in the LikeMinds Chat, allowing for seamless integration and realtime messaging in your application.
Steps to initiate a User
- Create a
InitiateUserRequest
object using user credentials. - For initiating a user, call
initiateUser()
function using the instance ofLMChatClient
class. - Use the response as per your requirement
//Set userId to custom user ID present in your database,
//or keep it blank to get one generated by the SDK
String userId = "3000";
String userName = "Tony Stark";
InitiateUserRequest request = (InitiateUserRequestBuiler()
..userName(userName)
..userId(userId)).build();
final LMResponse<InitiateUserResponse> response = await lmChatClient.initiateUser(request);
We suggest that you use the unique ID from your database for the user so that you do not have to save the one we generate.
Models
InitiateUserRequest
List of parameters for the InitiateUserRequest
class
Variable | Type | Description | Optional |
---|---|---|---|
userId | String | Unique ID for the userId | |
userName | String | Name of the userName | |
imageUrl | String | URL of the user's profile image | ✔️ |
isGuest | bool | Is the user a guest? | ✔️ |
InitiateUserResponse
List of parameters for the InitiateUserResponse
class
Variable | Type | Description | Optional |
---|---|---|---|
success | bool | API success status | |
errorMessage | String? | Error message in case of failure | ✔️ |
initiateUser | InitiateUser? | User and community details | ✔️ |
Initiate User
List of parameters used in InitiateUser
Variable | Type | Description | Optional |
---|---|---|---|
user | User | user data | |
community | Community | community data |
Member State
When building out your chat experience, you might want to moderate some actions based on the state of a community member. That's where member state comes in. With a single getMemberState()
function you can determine if a member is a CM, or not.
final bool isCM = await lmChatClient.getMemberState();