chat21/chat21-android-sdk

how to get IChatUser detail from email id?

vandanabpatel opened this issue · 2 comments

i want to start conversation directly can we get user detail by their email id if exist to firebase
can anyone guild me :)

if you have user mail, you can first retrive all contacts, like this:

private ContactsSynchronizer contactsSynchronizer;
contactsSynchronizer= ChatManager.getInstance().getContactsSynchronizer();
List<IChatUser> users = contactsSynchronizer.getContacts();

then check if with for statement if user mail exist. if true create new contact to start chat with:

for(IChatUser user: users) {
                    if (user.getEmail().equals(YOUR_EMAIL)) {

                        IChatUser contact = new ChatUser();
                        contact.setId(user.getId());
                        contact.setEmail(YOUR_EMAIL);
                        Log.d(TAG, "Open chat with contact: " + contact.toString());
                        ChatUI.getInstance().openConversationMessagesActivity(contact);
                        return;
                    }
                }

use openConversationMessagesActivity(contact) to start the chat directly with the last contact created.

Let me know if it works properly

thanks:) it works @gab-95