Integrating Chat SDK User profiles with your app
The Chat SDK stores it's own user object in Firebase. That means that if you already have your own user profiles, you will need to synchronize these with Chat SDK. Otherwise, the incorrect avatar and name will show up in the chat.
To do this you can use the following code:
1
// Get the current user
2
User currentUser = ChatSDK.core().currentUser();
3
​
4
// Update their name and avatar
5
currentUser.setName("name");
6
currentUser.setAvatarURL("URL");
7
​
8
// Push that data to Firebase
9
ChatSDK.core().pushUser().subscribe(() -> {
10
// Handle success
11
}, throwable -> {
12
// Handle failure
13
});
Copied!
Or you can use the SimpleAPI for convenience:
1
SimpleAPI.updateUser("name", "avatarURL");
Copied!
The best time to run this code is after authentication and whenever the user updates their profile information.
Last modified 9mo ago
Copy link