Listener / Delegate

This is a notifier for ChannelIO events.

This document tell you about listener / delegate's functions.

You can use this interface like this

ChannelIO.setListener(new ChannelPluginListener() {
  // code
});
ChannelIO.delegate = self
[ChannelIO setDelegate:self];

onShowMessenger

Called when messenger screen is appreared.
Generally called when user click channel button, call ChannelIO.showMessenger, ChannelIO.openChat

void onShowMessenger();
func onShowMessenger() {
}
- (void)onShowMessenger { 
}
ChannelIO.onShowMessenger(() => { });

onHideMessenger

Called when messenger screen is hidden.
Generally called when user click close button, call ChannelIO.hideMessenger, ChannelIO.sleep, ChannelIO.shutdown etc...

void onHideMessenger();
func onHideMessenger() {
}
- (void)onHideMessenger {
}
ChannelIO.onHideMessenger(() => { });

onChatCreated

Called when chat is created by user interaction (enter first message, select first support bot button)

void onChatCreated(String chatId);
func onChatCreated(chatId: String) {
}
- (void)onChatCreatedWithChatId:(NSString *)chatId { 
}
ChannelIO.onChatCreated((chatId) => { });

onBadgeChanged

Called when badge count is changed.

Use initial badge count by BootCallback > User.alert

void onBadgeChanged(int count);
func onBadgeChanged(alert: Int) {
}
- (void)onBadgeChangedWithAlert:(NSInteger)alert { 
}
ChannelIO.onBadgeChanged((count) => { });

onProfileChanged

Called when profile changed by user interaction (profile bot, change profile in settings)
This method is not called by ChannelIO.updateUser

void onProfileChanged(String key, @Nullable Object value);
func onProfileChanged(key: String, value: Any?) {
}
- (void)onProfileChangedWithKey:(NSString *)key value:(id)value {
}
ChannelIO.onProfileChanged((key, value) => { });

onUrlClicked

Called when user click url in chat, link buttons.
return true to block redirect by ChannelIO

boolean onUrlClicked(String url);

@Override
public boolean onUrlClicked(String url) {
  // SDK do not action when return true
  return true;
}
func onUrlClicked(url: URL) -> Bool {
    // SDK do not action when return true
    return true
}
- (BOOL)onUrlClickedWithUrl:(NSURL *)url {
  // SDK do not action when return true
  return YES;
}
let handleUrl = true;

ChannelIO.onUrlClicked((url, next) => {
    if (!handleUrl) {
        // Use this function if you want to open web view
        next();
    }
});

onPopupDataReceived

Called when popup data is received.
Generally called when manager talked, marketing message incomming.

See more about PopupData

void onPopupDataReceived(PopupData popupData)
func onPopupDataReceived(event: PopupData) {
}
- (void)onPopupDataReceivedWithEvent:(PopupData *)event {
}
ChannelIO.onPopupDataReceived((popupData) => { });

onPushNotificationClicked

Android

Called when user click push notification

@Override
public boolean onPushNotificationClicked(String chatId) {
  // SDK do not action when return true
  return true;
}