ChannelIO
boot
boot up channel to make it ready to use. Return a promise for boot result.
ChannelIO.boot(channelPluginSettings: Object)
paramter | type | description |
---|---|---|
channelPluginSettings | object | a 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)
paramter | type | description |
---|---|---|
animated | Boolean | whether display the launcher with animation or not |
hide
Hide ChannelIO
launcher
ChannelIO.hide(animated: Boolean)
paramter | type | description |
---|---|---|
animated | Boolean | whether display the launcher with animation or not |
open
Open ChannelIO
messenger
ChannelIO.open(animated: Boolean)
paramter | type | description |
---|---|---|
animated | Boolean | whether display the launcher with animation or not |
close
Close ChannelIO
messenger
ChannelIO.close(animated: Boolean)
paramter | type | description |
---|---|---|
animated | Boolean | whether display the launcher with animation or not |
openChat
Open ChannelIO
chat with given chat id
ChannelIO.openChat(chatId: String, animated: Boolean)
paramter | type | description |
---|---|---|
chatId | String | a chat id |
animated | Boolean | whether 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)
paramter | type | description |
---|---|---|
data | Object | a 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)
paramter | type | description |
---|---|---|
data | Object | a push data from notification |
ChannelIO.handlePushNotification(data).then((_) => {
//completion block
});
track
Track an event
ChannelIO.track(eventName: string, eventProperty: object)
paramter | type | description |
---|---|---|
eventName | string | name of event, its length should be less than 30 |
eventProperty | object | an 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 likeChannelIO.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
parameter | type | description |
---|---|---|
cb | Function | A callback function that takes count as parameter |
ChannelIO.onChangeBadge((count) => {
//do something with count
})
onReceivePush
Triggers when a push data has been received
parameter | type | description |
---|---|---|
cb | Function | A callback function that takes push data as parameter |
ChannelIO.onReceivePush((push) => {
//do something with push
})
onClickChatLink
Triggers when a user clicks on a link.
parameter | type | description |
---|---|---|
handle | Boolean | True if you will handle link event, otherwise false |
cb | Function | A callback function that takes link as parameter |
ChannelIO.onClickChatLink(true, (link) => {
//do something with link
})
willShowMessenger
Triggers when ChannelIO
messenger is about to display
parameter | type | description |
---|---|---|
cb | Function | A callback function that takes nothing |
ChannelIO.willShowMessenger(() => {
//do something
})
willHideMessenger
Triggers when ChannelIO
messenger is about to hide
parameter | type | description |
---|---|---|
cb | Function | A callback function takes nothing |
ChannelIO.willHideMessenger(() => {
//do something
})
Updated about 1 year ago