Login issue and getUser return null

After login once, it always give null when CometChat.getUser() call, so i have to login every time. It also occur in your demo app. I did same implementation as you provide in your demo app.
Thanks in advance.

1 Like

Hi @manish6314,

You need to use CometChat.getLoggedInUser() to get logged in user info.

CometChat.getUser(UID, new CometChat.CallbackListener<User>() is used to fetch particular user details.
You can refer the below documentation link.

Also can you provide us the link of demo app you are referring? So that we can check at our end.

1 Like

CometChat.getLoggedInUser(), If the method returns null , it indicates that the user is not logged in and you need to log the user into CometChat. I logged in succesfully when i login in my app but as soon as i try to open conversationListScreen() then it give me exception that user is not login then i have to re-login to see the conversation and when i destroy the app or MessageActivity then I have re-login to see details.

Hi @manish6314,

Can you share us the SDK version you are using and code snippet of CometChat.login() ?

SDK version : 2.0.3

private fun login(uid: String) {
if (CometChat.getLoggedInUser() == null) {
CometChat.login(“superhero1”, Constants.API_KEY, object : CometChat.CallbackListener() {
override fun onSuccess(user: User) {
Logger.e(Thread.currentThread(), “moveToInitialisation ${Gson().toJson(user)}”)
loadFragment(CometChatConversationListScreen())
}

            override fun onError(e: CometChatException) {

                Logger.e(Thread.currentThread(), "exception $e")

// Toast.makeText(, e.message, Toast.LENGTH_SHORT).show()
}
})
} else {
loadFragment(CometChatConversationListScreen())
}

}

I found issue, sorry to bother you.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.