initialize

parametertyperequireddescription
applicationUIApplicationOAn instance of the Application class.

Initialize the ChannelIO object. You need to invoke this method at least once before utilizing any of the other ChannelIO methods.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
	ChannelIO.initialize(application)
	...
	return true
}
@implementation AppDelegate
  
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [ChannelIO initialize:application];
  return YES;
}

initializeWindow

This is required when using SceneDelegate. It returns ChannelWindow with UIWindowScene.
Declare a class variable for ChannelIO. In the example below, the variable is named channelWindow.

parametertyperequireddescription
windowSceneUIWindowOAn instance of the UIWindowScene class.
class SceneDelegate: NSObject, UISceneDelegate {
  var channelWindow: UIWindow?

  func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    if let windowScene = scene as? UIWindowScene {
      channelWindow = ChannelIO.initializeWindow(with: windowScene)
    }
		...
  }
}
//  SceneDelegate.m

@interface SceneDelegate ()
@property (strong, nonatomic) UIWindow * channelWindow;
@end

@implementation SceneDelegate


- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
  _channelWindow = [ChannelIO initializeWindowWith:(UIWindowScene *)scene];
}
@end

delegate

The delegation object for ChannelIO.

ChannelIO.delegate = self
...
ChannelIO.delegate = self;

boot

Load the information necessary to use the SDK. After successful Boot, you are ready to use the features of Channel Talk. For more details, refer to Boot and About life cycle.

parametertyperequireddescription
configBootConfigOA configuration object for Boot. You can set the pluginKey and customize Channel button position, among other options.
completion((BootStatus, User?) -> Void)?XA callback from Boot that returns bootStatus and User.
let bootConfig = BootConfig(pluginKey: YOUR_PLUGIN_KEY)

ChannelIO.boot(with: bootConfig) { (status, user) in
	switch status {
	case .success:
		...
	default:
		...
	}
}
BootConfig *bootConfig = [[BootConfig alloc] init];
[bootConfig setPluginKey:YOUR_PLUGIN_KEY];
[ChannelIO bootWith:bootConfig completion:^(BootStatus status, User *user) {
  if (status == BootStatusSuccess && user != nil) {
    // success
  } else {
    // show failed reason from bootStatus
  }
}];

sleep

Disables all features except for receiving system push notifications and using the Track. Real-time functionalities (such as chat, marketing pop-ups, etc.) cannot be used due to the disconnected socket communication with Channel Talk servers. For more detailed guidance, refer to About life cycle.

ChannelIO.sleep()
...
[ChannelIO sleep];
...

shutdown

Disconnects the SDK from the channel. The use of all features of the SDK is suspended. For more detailed guidance, refer to About life cycle.

ChannelIO.shutdown()
...
[ChannelIO shutdown];
...

showChannelButton

Displays the Channel button on the global screen.

ChannelIO.showChannelButton()
...
[ChannelIO showChannelButton];
...

hideChannelButton

Hides the Channel button on the global screen.

ChannelIO.hideChannelButton()
...
[ChannelIO hideChannelButton];
...

showMessenger

Displays the messenger.

ChannelIO.showMessenger()
...
[ChannelIO showMessenger]
...

hideMessenger

Hides the messenger.

ChannelIO.hideMessenger()
...
[ChannelIO hideMessenger];
...

openChat

Opens User chat. If the chatId exists, open it; otherwise, start a new chat.

parametertyperequireddescription
chatIdString?XThis is the chat ID. If the chatId is invalid or nil, a new user chat is opened.
messageString?XThis is the pre-filled message in the message input field when opening a new chat. It is valid when chatId is nil.
// Open chat id is '123'
ChannelIO.openChat(with: "123", message: nil)

// Same as ChannelIO.openChat("123", nil);
// When chat id parameter is not null, message parameter is ignored.
ChannelIO.openChat(with: "123", message: "Text here")

// Open new chat like click start new chat in home
ChannelIO.openChat(with: nil, message: nil)

// Open new chat with "Text here" in input box. 
// If support bot is enabled, open support bot instead.
ChannelIO.openChat(with: nil, message: "Text here")
// Open chat id is '123'
[ChannelIO openChatWith:@"123" message: nil];

// Same as ChannelIO.openChat("123", null);
// When chat id parameter is not null, message parameter is ignored.
[ChannelIO openChatWith:@"123" message: @"Text here"];

// Open new chat like click start new chat in lounge
[ChannelIO openChatWith:nil message: nil];

// Open new chat with "Text here" in input box. 
// If support bot is enabled, open support bot instead.
[ChannelIO openChatWith:nil message: @"Text here"];

openSupportBot

Opens User chat to run a specific Support bot.

parametertyperequireddescription
supportBotIdString?XThis is the support bot's ID. If supportBotId is invalid or nil, the chat room is closed.
messageString?XThis message will be displayed in the input field after completing the support bot operation.
// Open Support bot id is '123'
ChannelIO.openSupportBot(with: "123", message: nil)

// Open Support bot id is '123'
// After the Support bot has completed, 'Text here' will be filled on the input box.
ChannelIO.openSupportBot(with: "123", message: "Text here")
// Open Support bot id is '123'
[ChannelIO openSupportBotWith: @"123" message: nil];

// Open Support bot id is '123'
// After the Support bot has completed, 'Text here' will be filled on the input box.
[ChannelIO openSupportBotWith: @"123" message: @"Text Here"];

track

Tracks the user's events. For more detailed instructions, refer to the event tracking documentation.

parametertyperequireddescription
eventNameStringOThis is the name of the event to track, with a maximum length of 30 characters.
eventProperty[String: Any]?XThis is additional information about the event.
// Only send event name
ChannelIO.track(eventName: EVENT_NAME, eventProperty: nil)

// Event with properties
var eventProperties: [String:Any] = [:]
eventProperties[PROPERTY_KEY_1] = STRING_VALUE
eventProperties[PROPERTY_KEY_2] = INT_VALUE
ChannelIO.track(eventName: EVENT_WITH_PROPERTIES_NAME, eventProperty: eventProperties)
// Only send event name
[ChannelIO trackWithEventName:@"EVENT_NAME" eventProperty:nil];
  
// Event with properties
NSDictionary<NSString *, id> *eventProperties = [NSMutableDictionary dictionary];
[eventProperties setValue:STRING_VALUE forKey:PROPERTY_KEY_1];
[eventProperties setValue:INT_VALUE forKey:PROPERTY_KEY_2];
[ChannelIO trackWithEventName:@"EVENT_WITH_PROPERTIES_NAME" eventProperty:eventProperties];

setPage

Sets the name of the screen when the track is called. If track is called before setPage, the event will not reflect the page information.

parametertyperequireddescription
pageString?XThis is the screen name when track is called. When calling .track(nil), the event's page is set to null.
ChannelIO.setPage(page)
[ChannelIO setPage:page]

resetPage

Resets the name of the screen when track is called. The default setting is the name of the ViewController that calls track.

ChannelIO.resetPage()
ChannelIO.resetPage();

updateUser

Modifies user information.

parametertyperequireddescription
userData[String: Any?]OThis is the user information to be updated.
completion((Bool, User?) -> Void)?XThis returns the result of user information modification.
var profile: [String: Any] = [:]

profile[OTHER_KEY] = OTHER_VALUE
  
let userData = UpdateUserParamBuilder()
  .with(language: .english)
  .with(profile: profile)
  .build()
    
ChannelIO.updateUser(param: userData) { (error, user) in
  if let user = user, error == nil {
    ...
  } else if let error = error {
    ...
  }
}
UpdateUserParamObjcBuilder *builder = [[UpdateUserParamObjcBuilder alloc] init];

// name
[builder withProfileKey:@"name" value:USER_NAME];

// mobileNumber
[builder withProfileKey:@"mobileNumber" value:@"+~~~"];
  
// email
[builder withProfileKey:@"email" value:EMAIL];
  
// avatar url
[builder withProfileKey:@"avatarUrl" value:AVATAR_URL];
  
// other
[builder withProfileKey:@"OTHER_KEY" value:OTHER_VALUE];

[builder withLanguage:LanguageOptionEnglish];

[ChannelIO updateUserWithParam:[builder build] completion:^(NSError * error, User * user) {
  if (user != nil && error == nil) {
    // success, result data is user
  } else (error != nil) {
    // error, see error
  }
}];

addTags

Adds tags to the user.

parametertyperequireddescription
tags[String]O• The maximum number of tags that can be added is 10.
• Tags are stored in lowercase.
• Any tags that have already been added will be ignored.
• nil, empty strings, or lists containing them are not allowed.
completion((Error?, User?) -> Void)?XWhen adding tags, it returns a User object. If the addition fails, it returns an error.
var tags: [String] = []
tags.append(TAG_1)
tags.append(TAG_2)
tags.append(TAG_3)
tags.append(TAG_4)

ChannelIO.addTags(tags) { (error, user) in
  if let user = user {
		...
  } else if error = error {
    ...
  }
}
NSMutableArray<NSString *> testTags = [NSMutableArray arrayWithCapacity:4];
[testTags addObject:@"tag1"];
[testTags addObject:@"tag2"];
[testTags addObject:@"tag3"];
[testTags addObject:@"tag4"];
  
[ChannelIO addTags:testTags completion:^(NSError * error, User * user) {
  if user != nil {
    // success
  } else if error != nil {
    // check reason
  }
}];

removeTags

Removes tags from the user, ignoring any tags that do not exist.

parametertyperequireddescription
tags[String]OThese are the tags to be removed. Null, empty strings, or lists containing them are not allowed.
completion((Error?, User?) -> Void)?XWhen removing tags, it returns a Userobject. If the removal fails, it returns an error.
var tags: [String] = []
tags.append(TAG_1)
tags.append(TAG_2)
tags.append(TAG_3)
tags.append(TAG_4)

ChannelIO.removeTags(tags) { (error, user) in
  if let user = user {
		...
  } else if error = error {
    ...
  }
}
NSMutableArray<NSString *> testTags = [NSMutableArray arrayWithCapacity:4];
[testTags addObject:@"tag1"]
[testTags addObject:@"tag2"]
[testTags addObject:@"tag3"]
[testTags addObject:@"tag4"]
  
[ChannelIO removeTags:testTags completion:^(NSError * error, User * user) {
  if user != nil {
    // success
  } else if error != nil {
    // check reason
  }
}];

initPushToken

Informs ChannelTalk about updates to the device token.

parametertyperequireddescription
deviceTokenDataOThis is the device token required for receiving push notifications.
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
	ChannelIO.initPushToken(deviceToken: deviceToken)
	...
}
// AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate, UNUserNotificationCenterDelegate>

@property (nonatomic, strong) UIWindow *window;

@end


// AppDelegate.m
@implementation AppDelegate

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  [ChannelIO initPushTokenWithDeviceToken:deviceToken.map]
}

isChannelPushNotification

It checks if the push data should be processed by the SDK.

parametertyperequireddescription
_[AnyHashable: Any]OThis is the `userInfo object received through push notifications.
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
	let userInfo = response.notification.request.content.userInfo
	if ChannelIO.isChannelPushNotification(userInfo) {
	  ...    
	}
  completionHandler()
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response 
withCompletionHandler:(void (^)())completionHandler {
    NSDictionary *userInfo = response.notification.request.content.userInfo;
  // This line
  if ([ChannelIO isChannelNotification:userInfo]) {
    [ChannelIO receivePushNotification:userInfo completion: nil];
    [ChannelIO storePushNotification: userInfo];
  }
  completionHandler();
}

receivePushNotification

Notifies Channel Talk that the user has received a push notification.

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
	let userInfo = response.notification.request.content.userInfo
	if ChannelIO.isChannelPushNotification(userInfo) {
		ChannelIO.receivePushNotification(userInfo)
	  ...    
	}
  completionHandler()
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response 
withCompletionHandler:(void (^)())completionHandler {
  NSDictionary *userInfo = response.notification.request.content.userInfo;
  if ([ChannelIO isChannelNotification:userInfo]) {
    // This line
    [ChannelIO receivePushNotification:userInfo completion: nil];
    [ChannelIO storePushNotification: userInfo];
  }
  completionHandler();
}

storePushNotification

Stores push information on the device.

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
	let userInfo = response.notification.request.content.userInfo
	if ChannelIO.isChannelPushNotification(userInfo) {
		ChannelIO.storePushNotification(userInfo)
	  ...    
	}
  completionHandler()
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response 
withCompletionHandler:(void (^)())completionHandler {
  NSDictionary *userInfo = response.notification.request.content.userInfo;
  if ([ChannelIO isChannelNotification:userInfo]) {
    [ChannelIO receivePushNotification:userInfo completion: nil];
    // This line
    [ChannelIO storePushNotification: userInfo];
  }
  completionHandler();
}

hasStoredPushNotification

Check for any saved push notifications from the Channel.

class ViewController : UIViewController {
  override func viewDidLoad() {
    super.viewDidLoad()
    
    if ChannelIO.hasStoredPushNotification() {
      ...
    }
  }
}
@implementation ViewController

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    
  // This line
  if ([ChannelIO hasStoredPushNotification]) {
        [ChannelIO openStoredPushNotification]
  }
}

@end

openStoredPushNotification

Opens a user chat using the stored push information on the device through storePushNotifcation .

class ViewController : UIViewController {
  override func viewDidLoad() {
    super.viewDidLoad()
    
    ChannelIO.openStoredPushNotification()
		...
  }
}
@implementation ViewController

- (void)viewDidLoad { 
    [super viewDidLoad]; 

  if ([ChannelIO hasStoredPushNotification]) {
    // This line
    [ChannelIO openStoredPushNotification]
  }
}

@end

isBooted

Verify that the SDK is in a Boot state.

ChannelIO.isBooted
ChannelIO.isBooted

setDebugMode

Sets the debug mode. If set to true, log messages will be displayed.

ChannelIO.setDebugMode(with: true)
[ChannelIO setDebugModeWith:@(YES)]

setAppearance

Configures the SDK's theme.

parametertyperequireddescription
appearanceAppearanceOIf specified as .light or .dark, it locks the theme to the respective mode. If specified as .system, it follows the device's system theme.
ChannelIO.setAppearance(.light)
[ChannelIO setAppearance:AppearanceLight];

applyAppearance deprecated

❗️

Renamed to setAppearance.

Sets the appearance of the SDK.

parametertyperequireddescription
appearanceAppearanceOIf specified as .light or .dark, it locks the theme to the respective mode. If specified as .system, it follows the device's system theme.
ChannelIO.applyAppearance(.light)
[ChannelIO setAppearance:AppearanceLight];