Callback
Register Delegate
as follows to handle channel event.
// Register delegate to handle channel event
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[[TalkPlus sharedInstance] addChannelDelegate:self tag:@"tagHere"];
}
// Important! Deregister delegate to prevent memory leak
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[[TalkPlus sharedInstance] removeChannelDelegate:@"tagHere"];
}
// Register delegate to handle channel event
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
TalkPlus.sharedInstance()?.add(self, tag: "tagHere")
}
// Important! Deregister delegate to prevent memory leak
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
TalkPlus.sharedInstance()?.removeChannelDelegate("tagHere")
}
The defined Delegate events are shown below.
@protocol TPChannelDelegate <NSObject>
// callback fired when new member is added to the channel
-(void)memberAdded:(TPChannel *)tpChannel users:(NSArray<TPMember *> *)users;
// callback fired when member leaves the channel
-(void)memberLeft:(TPChannel *)tpChannel users:(NSArray<TPMember *> *)users;
// callback fired when new message is received in the channel
-(void)messageReceived:(TPChannel *)tpChannel message:(TPMessage *)tpMessage;
// callback fired when message is deleted in the channel
-(void)messageDeleted:(TPChannel *)tpChannel message:(TPMessage *)tpMessage;
// callback fired when a new channel is created
-(void)channelAdded:(TPChannel *)tpChannel;
// callback fired when the channel is updated
-(void)channelChanged:(TPChannel *)tpChannel;
// callback fired when the channel is deleted
-(void)channelRemoved:(TPChannel *)tpChannel;
// callback fired when member is muted
-(void)memberMuted:(TPChannel *)tpChannel users:(NSArray<TPMember *> *)users;
// callback fired when member is unmuted
-(void)memberUnmuted:(TPChannel *)tpChannel users:(NSArray<TPMember *> *)users;
// callback fired when member is banned
-(void)memberBanned:(TPChannel *)tpChannel users:(NSArray<TPMember *> *)users;
// callback fired when member is unbanned
-(void)memberUnbanned:(TPChannel *)tpChannel users:(NSArray<TPMember *> *)users;
@end
Last updated