Callback

You can register callback as follows:

The tag value is a string value for registering or deleting channel events, and should be set to a unique string value.

// Register channel listener to handle channel event
TalkPlusAPI.addChannelListener(
        tag,
        ChannelListener(onMemberAdded: (TPChannel channel, List<TPMember> users) {
            // callback fired when new member is added to the channel
        }, onMemberLeft: (TPChannel channel, List<TPUser> users) {
            // callback fired when member leaves the channel
        }, onChannelAdded: (TPChannel channel) {
            // callback fired when a new channel is created
        }, onChannelChanged: (TPChannel channel) {
            // callback fired when the channel is updated
        }, onChannelRemoved: (TPChannel channel) {
            // callback fired when the channel is deleted
        }, onMessageReceived: (TPChannel channel, TPMessage message) {
            // callback fired when new message is received in the channel
        }, onMessageDeleted: (TPChannel channel, TPMessage message) {
            // callback fired when message is deleted in the channel
        }, onPublicChannelAdded: (TPChannel channel) {
            // callback fired when a new public channel is created
        }, onPublicChannelChanged: (TPChannel channel) {
            // callback fired when a public channel is updated
        }, onPublicChannelRemoved: (TPChannel channel) {
            // callback fired when a public channel is deleted
        }, onPublicMemberAdded: (TPChannel channel, List<TPMember> users) {
            // callback fired when new member is added to a public channel
        }, onPublicMemberLeft: (TPChannel channel, List<TPMember> users) {
            // callback fired when member leaves a public channel
        }, onMemberMuted: (TPChannel channel, List<TPMember> users) {
            // callback fired when member is muted
        }, onMemberUnMuted: (TPChannel channel, List<TPMember> users) {
            // callback fired when member is unmuted
        }, onPublicMemberMuted: (TPChannel channel, List<TPMember> users) {
            // callback fired when member is muted in a public channel
        }, onPublicMemberUnMuted: (TPChannel channel, List<TPMember> users) {
            // allback fired when member is unmuted in a public channel
        }, onMemberBanned: (TPChannel channel, List<TPMember> users) {
            // callback fired when member is banned
        }, onMemberUnBanned: (TPChannel channel, List<TPMember> users) {
            // callback fired when member is unbanned
        }, onPublicMemberBanned: (TPChannel channel, List<TPMember> users) {
            // callback fired when member is banned in a public channel
        }, onPublicMemberUnBanned: (TPChannel channel, List<TPMember> users) {
            // callback fired when member is unbanned in a public channel
        }
    )
);

// Deregister channel listener
TalkPlusAPI.removeChannelListener(tag);

Last updated