ChannelIO

boot

boot up channel to make it ready to use. Return a promise for boot result.

ChannelIO.boot(channelPluginSettings: Object)
paramtertypedescription
channelPluginSettingsobjecta ChannelPluginSettings object contains informations to initialize channel plugin
var settings = {
  "pluginKey":"YOUR_PLUGIN_KEY" 
};

ChannelIO.boot(settings).then((result) => {
  //boot completed
})

shutdown

shutdown ChannelIO

ChannelIO.shutdown()

show

Show ChannelIO launcher

ChannelIO.show(animated: Boolean)
paramtertypedescription
animatedBooleanwhether display the launcher with animation or not

hide

Hide ChannelIO launcher

ChannelIO.hide(animated: Boolean)
paramtertypedescription
animatedBooleanwhether display the launcher with animation or not

open

Open ChannelIO messenger

ChannelIO.open(animated: Boolean)
paramtertypedescription
animatedBooleanwhether display the launcher with animation or not

close

Close ChannelIO messenger

ChannelIO.close(animated: Boolean)
paramtertypedescription
animatedBooleanwhether display the launcher with animation or not

openChat

Open ChannelIO chat with given chat id

ChannelIO.openChat(chatId: String, animated: Boolean)
paramtertypedescription
chatIdStringa chat id
animatedBooleanwhether display the launcher with animation or not

isChannelPushNotifcation

Check whether a given data is for channel push notification. Return a promise the result.

ChannelIO.isChannelPushNotification(data: Object)
paramtertypedescription
dataObjecta push data from notification
ChannelIO.isChannelPushNotification(data).then((result) => {
  if (result) {
   //is from channel 
  } else {
   //other push notification
  }
});

handlePushNotification

Handle a given push data

ChannelIO.handlePushNotification(data: Object)
paramtertypedescription
dataObjecta push data from notification
ChannelIO.handlePushNotification(data).then((_) => {
	//completion block
});

track

Track an event

ChannelIO.track(eventName: string, eventProperty: object)
paramtertypedescription
eventNamestringname of event, its length should be less than 30
eventPropertyobjectan object contains key/value information
ChannelIO.track('Order', {
  "price": 100,
  "currency": 'USD'
});

📘

About callback listeners

ChannelIO only maintains callback listeners only one per each event. That means, if you implement like

ChannelIO.onChangeBadge((count) => {
  console.log('first count is ' +  count);
})

ChannelIO.onChangeBadge((count) => {
  console.log('second count is ' + count);
})

only the second log will be executed when the callback is called. The reason behind this is because we want to eliminate unexpected behavior by misusing these callbacks. If you really need to listen same event on different place simultaneously, please use ChannelEventEmitter directly.

onChangeBadge

Triggers when user's badge has been changed

parametertypedescription
cbFunctionA callback function that takes count as parameter
ChannelIO.onChangeBadge((count) => {
   //do something with count
})

onReceivePush

Triggers when a push data has been received

parametertypedescription
cbFunctionA callback function that takes push data as parameter
ChannelIO.onReceivePush((push) => {
  //do something with push
})

onClickChatLink

Triggers when a user clicks on a link.

parametertypedescription
handleBooleanTrue if you will handle link event, otherwise false
cbFunctionA callback function that takes link as parameter
ChannelIO.onClickChatLink(true, (link) => {
  //do something with link
})

willShowMessenger

Triggers when ChannelIO messenger is about to display

parametertypedescription
cbFunctionA callback function that takes nothing
ChannelIO.willShowMessenger(() => {
  //do something 
})

willHideMessenger

Triggers when ChannelIO messenger is about to hide

parametertypedescription
cbFunctionA callback function takes nothing
ChannelIO.willHideMessenger(() => {
  //do something 
})