Event Listener

The Javascript SDK provides interfaces to listen to various events on the client app. Through these interfaces, TapTalk.io notifies the client app of events that happen on your app.

TapTalk.io provides event listeners to notify events to the client app. You will need to register the listener objects to receive event callbacks from TapTalk.io.

Event Listener

Description

Listens to general event changes in the application

Listens to events when a new/updated message is received by the application

Listens to changes to chat room's state in the room list

Listens to room status events such as typing events and online status

Listens to contact related events such as block or unblock contact

TapListener

General events such as notifications will be notified through TapListener. A TapListener instance is required when initializing TapTalk.

taptalk.addTapListener({
      onTapTalkRefreshTokenExpired: () => {
        setIsModalRefreshReconnectShow(true);
      }
})

TapListener listens to changes in the following methods:

Method Name

Invoked When

onTapTalkRefreshTokenExpired()

User's refresh token has expired. An authentication with a new auth ticket is required.

TapCoreMessageListener

TapCoreMessageListener listens to message-related events, such as receiving new or updated message. TapCoreMessageListener can be registered through the TapCoreMessageManager class.

tapCoreChatRoomManager.addMessageListener({
        onReceiveNewMessage: (messageModel) => {
          // do action here
        },

        onReceiveUpdateMessage: (messageModel) => {
          // do action here
        }
})

Method Name

Invoked When

onReceiveNewMessage()

A new message is received. Returns the newly received message.

onReceiveUpdatedMessage()

An updated message is received. Returns the updated message.

TapCoreRoomListListener

Changes to a chat room's state, such as pin and mute events are notified through TapCoreRoomListListener. An instance of TapCoreRoomListListener can be registered from the TapCoreRoomListManager class.

tapCoreRoomListManager.addRoomListListener({
    onChatRoomDeleted: (roomID) => {
        // do action here
    }
});
Method Name
Invoked When

onChatRoomDeleted()

The active user deleted a chat room. Returns the room ID of the deleted room.

TapCoreChatRoomListener

Room status events such as typing events and online status are notified through TapCoreChatRoomListener. An instance of TapCoreChatRoomListener can be registered from the TapCoreChatRoomManager class.

tapCoreChatRoomManager.addRoomStatusListener( {
        onReceiveStartTyping: (roomID, userModel) => {
          // do action here
        },

        onReceiveStopTyping: (roomID, userModel) => {
          // do action here
        },

        onReceiveOnlineStatus: (userModel, isOnline, lastActive) => {
          // do action here
        }
 })

Method Name

Invoked When

onReceiveStartTyping()

Another user starts typing a message in a chat room. Returns the room ID and typing user.

onReceiveStopTyping()

Another user stops typing a message in a chat room. Returns the room ID and typing user.

onReceiveOnlineStatus()

Another user comes online or offline. Returns the updated user, online status, and the updated user's last active time stamp.

TapCoreContactListener

Contact related events such as block/unblock are notified through TapCoreContactListener. An instance of TapCoreContactListener can be registered from the TapCoreContactManager class.

tapCoreContactManager.addContactListener({
    onContactBlocked: (user) => {
    
    },
    onContactUnblocked: (user) => {
    
    }
});

Method Name

Invoked When

onContactBlocked()

Active user blocks another user. Returns the blocked user.

onContactUnblocked()

Active user unblocks another user. Returns the unblocked user.

Last updated