How to use the @cometchat-pro/react-native-chat.CometChat.addUserListener function in @cometchat-pro/react-native-chat

To help you get started, we’ve selected a few @cometchat-pro/react-native-chat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cometchat-pro-samples / react-native-chat-app / chatApp / src / HomeScreen.js View on Github external
addUserListner(){
        let  listenerID = "CONTACT_USER_LISTNER";
        let that=this;
        CometChat.addUserListener(
            listenerID,
            new CometChat.UserListener({
                onUserOnline: onlineUser => {
                    /* when someuser/friend comes online, user will be received here */
                    console.log("On User Online:", { onlineUser });
                    that.state.users.map(user=>{
                        if (user.uid == onlineUser.uid){
                            user.status="online"
                            that.setState({users:[...that.state.users]})
                        }
                    })
                },
                onUserOffline: offlineUser => {
                    /* when someuser/friend went offline, user will be received here */
                    console.log("On User Offline:", { offlineUser });
                    that.state.users.map(user=>{
github cometchat-pro-samples / react-native-chat-app / chatApp / src / ChatScreen.js View on Github external
addUserListner(){
        var listenerID = "CHAT_SCREEN_USER_LISTNER";

        CometChat.addUserListener(
            listenerID,
            new CometChat.UserListener({
                onUserOnline: onlineUser => {
                    /* when someuser/friend comes online, user will be received here */
                    console.log("On User Online:", { onlineUser });

                    if(onlineUser.uid == uid){
                        status = "Online"
                        this.changeTypingText(status)
                    }
                },
                onUserOffline: offlineUser => {
                    /* when someuser/friend went offline, user will be received here */
                    console.log("On User Offline:", { offlineUser });
                    if(offlineUser.uid == uid){
                        status = "Offline"