The delegate allows the reception of event callbacks from the SDK. Ensure that the delegate object isn’t nil. Here's an example:

class ViewController: ChannelPluginDelegate {

  override func viewDidLoad() {
    ...
    ChannelIO.delegate = self
    ...
  }
}
[ChannelIO setDelegate:self];

onShowMessenger

Invoked when the Messenger is displayed. Examples include:

  • calls showMessenger
  • calls openChat
  • When the user opens messenger through Channel button
class ViewController: ChannelPluginDelegate {

  func onShowMessenger() {
   ...

  }
}
- (void)onShowMessenger { 
}

onHideMessenger

Invoked when the messenger is hidden. Examples include:

  • A call to hideMessenger
  • A call to sleep
  • A call to shutdown
  • When the user explicitly closes the messenger, such as by clicking the X button.
class ViewController: ChannelPluginDelegate {

  func onHideMessenger() {
   ...
  }
}
- (void)onHideMessenger {
}

onChatCreated

Invoked when the SDK finishes creating a new chat. Examples are the following:

  • Explicitly creating a chat by the user, such as by clicking a new Chat button.
  • calls openChat with chatId = nil
class ViewController: ChannelPluginDelegate {

  func onChatCreated(chatId: String) {
   ...
  }
}
- (void)onChatCreatedWithChatId:(NSString *)chatId { 
}

onBadgeChanged(count: Int) Deprecated

❗️

You shoud use onBadgeChanged(unread: Int, alert: Int).

Invoked when the count of the user’s badge is changed. Examples include:

  • boot
  • When the user receives messages or marketing messages
class ViewController: ChannelPluginDelegate {

  func onBadgeChanged(alert: Int) {
   ...
  }
}
- (void)onBadgeChangedWithAlert:(NSInteger)alert { 
}

onBadgeChanged(unread: Int, alert: Int)

Invoked when the number of notifications changes or at boot. The details of this method's parameters, unread, and alert are as follows:

  • unread : The number of all unread notifications the user has. It includes the number of alert. It is displayed as a red dot on the Channel button.
  • alert : The number of important notifications that the user has not read. It is displayed as a number on the Channel button.
class ViewController: ChannelPluginDelegate {

  func onBadgeChanged(unread: Int, alert: Int) {
   ...
  }
}
- (void)onBadgeChangedWithUnread:(NSInteger)unread alert:(NSInteger)alert {
}

onFollowUpChanged

This callback is invoked when the user changes Follow-up information. ChannelIO.updateUser does not trigger it. Values in dictionaries are nullable.

class ViewController: ChannelPluginDelegate {

  func onFollowUpChanged(data: [String : Any]) {
   ...
  }
}
- (void)onFollowUpChangedWithData:(NSDictionary<NSString *,id> *)data {
}

onUrlClicked

Invoked when the user clicks a link in the chat or clicks the link button.
If this method returns true, URL redirection performed by the SDK will not work.

class ViewController: ChannelPluginDelegate {

  func onUrlClicked(url: URL) -> Bool {
   ...
  }
}
- (BOOL)onUrlClickedWithUrl:(NSURL *)url {
  // SDK do not action when return true
  return YES;
}

onPopupDataReceived

Invoked when receiving In-app message popup. Examples include:

  • Receiving a message from the manager
  • Receiving a marketing message

Refer to the PopupData documentation for details on the events that are parameters of this function.

class ViewController: ChannelPluginDelegate {

  func onPopupDataReceived(event: PopupData) {
   ...
  }
}
- (void)onPopupDataReceivedWithEvent:(PopupData *)event {
}