Hi SendBird Team,
I am trying to create Users with meta data in UiKit. How can i create user with meta data in React.js UiKit?
Hi @vcs_account
When you declare:
<SendbirdProvider
appId={appId}
userId={userId}
nickname={nickname}
profileUrl={profileUrl}
>
....
</>
A user will be created(if the user is not present in the server).
To add extra meta data, you should get the SDK instance refer: (https://codesandbox.io/s/2-5-customizing-chatinput-wgi9d?file=/src/CustomizedMessageInput.js:3709-3756)
And then call user.updateMetaData
or user.createMetaData
as in the link below
Thanks @Sravan_S,
Actually I have my Users List which are saved in my database. I want to add these Users List into sendbird server in one go.
when i initialize sendbird app then i send the list of Users and creates all friends on sendbird server.
how can i create this list in one go?
Ah, for this, most probably you need server support. Let me get you in touch with someone who can help
Hey @vcs_account,
I would also recommend using the Platform API call to create users from a security perspective. As you can only issue access/session tokens via the Platform API.
Thanks @Alex_Preston,
This link is very helpful for me.
Thanks, @Sravan_S for guidance and help.
@Sravan_S
I want to get specific users list in UIKit . Let’s Suppose I have 4 users A , B , C , D
If User A is logIn then he shows only C , D Users in Users list and when User B
is login then only A , D Users Show in Users List.
Do you have any code sample regarding to this situation.
So the recommended option here would be to customizing applicationUserListQuery
Maybe add metaDataKeyFilter / metaDataValuesFilter for users and use it to filter userlist?
If you cannot support your use case this way, there is another option(sadly we do not have example for it for now) I can get back to you
I will give you this
Thanks @Sravan_S,
This is very helpful for me and Thanks for Technical support.
@Sravan_S,
Can i use this piece of code for UiKit. If i can use then tell me about that how can i use?
var userIds = ['John', 'Harry'];
groupChannel.inviteWithUserIds(userIds, function(response, error) {
if (error) {
return;
}
});
@Sravan_S,
I use this code in UIKit but data is not filtering on User metadata please guide me.
queries={{
channelListQuery: {
includeEmpty: true,
order: ‘latest_last_message’,
customTypesFilter: [props.areaId]
},
applicationUserListQuery: {
limit: 3,
isLoading: false,
metaDataKeyFilter : ‘areaGuid’,
}
}}
Internally we use this method internally, actually, you can call it from a component that is wrapped with withSendBird
same as in the input example. You can acccess SDK, and you should have current channel Id in the upperscope.
You can get channel and then call groupChannel.inviteWithUserIds
example
const CustomizedComponent = (props) => {
const {
sdk,
// from parent component
channelUrl,
usersToAdd, // ['u1', 'u2']
} = props
sdk.GroupChannel.getChannel(channelUrl, (channel) => {
channel.inviteWithUserIds(usersToAdd, (response, error) => {
if (error) {
return;
}
});
})
}
const mapStoreToProps = store => {
const sdk = sendBirdSelectors.getSdk(store);
return {
sdk,
};
};
export default withSendBird(CustomizedComponent, mapStoreToProps);
Note that all components should be inside <SendBirdProvider /
> tree
@vcs_account about the
I use this code in UIKit but data is not filtering on User metadata please guide me.
Please do not override isLoading
and next
You have to use metaDataKeyFilter and metaDataValuesFilter together ->
See the example here
Fox example, in your case, it can be
applicationUserListQuery: {
limit: 30,
metaDataKeyFilter: 'areaGuid',
metaDataValuesFilter: ['seattle-12', 'seoul-45', 'tokyo-1']
},
@Sravan_S Thanks,
Awesome stuff for me. Thanks for technical support.
@Sravan_S,
I am getting Users List from sendbird server but i am getting only 100 users but i want to get more than 100. Scrollbar effect is not working in my Code. Can you guide me what is happening there?
queries={{
channelListQuery: {
includeEmpty: true,
order: 'latest_last_message',
customTypesFilter: [props.areaId]
}
,
applicationUserListQuery: {
isLoading: false,
hasNext:true,
limit:100,
metaDataKeyFilter: props.areaName,
metaDataValuesFilter: [props.areaId],
}
}}