addUserListener not firing when User comes online or goes offline

Hi Support,

Using Version 2.0.7 beta1.

I have added below code,

getUserOnlineStatus: function()
var listenerID = “UNIQUE_LISTENER_ID”;
new CometChat.UserListener({
onUserOnline: onlineUser => {
/* when someuser/friend comes online, user will be received here /
console.log(“On User Online:”, { onlineUser });
onUserOffline: offlineUser => {
when someuser/friend went offline, user will be received here */
console.log(“On User Offline:”, { offlineUser });

registered this listener after user login (CometChat.login), but i am not receiving if any other user comes online and goes offline.

Please help me to identify the issue.

Hello @Mycortexdev,

I would advise you to update to the latest version of the SDK v2.0.12. Please make sure you have called subscribePresenceForAllUsers() of the AppSettingsBuilder in CometChat.init(). Also, you can receive real-time events only if you are connected to our WS servers. You can use Connection Listeners to get real-time updates about the connection status to our WS servers. You can also get your current connection status. You can find more detail about Connection Listeners here.

Warm Regards,

CometChat Pro
Mayur Bhandari