addUserListener event is not working properly.
mubashshir-uneecops opened this issue · 1 comments
mubashshir-uneecops commented
The event fires for some users only. It does not work for all the users.
This is how i subscribe to listener
addUserEventListner() {
CometChat.addUserListener(
this.userListenerID,
new CometChat.UserListener({
onUserOnline: onlineUser => {
console.log('~~~~ On User Online:', onlineUser);
const fi = this.userListArray.findIndex(ele => ele.uid == onlineUser.uid);
if (fi >= 0) {
this.userListArray[fi].status = 'online';
}
},
onUserOffline: offlineUser => {
console.log('~~~~ On User Offline:', offlineUser);
const fi = this.userListArray.findIndex(ele => ele.uid == offlineUser.uid);
if (fi >= 0) {
this.userListArray[fi].status = 'offline';
}
}
})
);
}
This is how i initialize my app
initCometChat() {
this.cometAppId = this._shared.tokenInfo.ChatAppId;
const region = "us";
const appSetting = new CometChat.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(region).build();
CometChat.init(this.cometAppId, appSetting).then(
() => {
console.log('~~~~ Initialization completed successfully');
this.onCometLogin();
},
error => {
console.log('~~~~ Initialization failed with error:', error);
}
);
}
mubashshir-uneecops commented
Now it is working.