ChannelIO
initialize
The initialize function is responsible for initializing ChannelIO
and should be invoked prior to any other methods of ChannelIO
.
Parameter | Type | Default Value | Description |
---|---|---|---|
application | @NonNull Application | Required | An Application instance. |
attachView | boolean | true | When set to true , the SDK will automatically attach a view to display the channel button and marketing pop-ups within your activity. To exclude specific activities from this view attachment, use @SkipAttachChannelView . If set to false , the view won't be automatically attached, and you'll need to use the ChannelPluginListener ChannelPluginListener to display an appropriate UI. |
setListener
Sets a callback to be invoked when an event occurs.
Parameter | Type | Default Value | Description |
---|---|---|---|
listener | @Nullable ChannelPluginListener | Required | A listener instance to be invoked when the event occurs . If null, the listener will be removed. |
clearListener
Removes a listener instance previously set by setListener
. A shortcut for setListener(null)
.
boot
Prepares for channel-specific features such as showing a messenger and a real-time chat. See how to use Channel Talk. Use the bootCallback
parameter to define the task to be done after the boot is complete.
Parameter | Type | Default Value | Description |
---|---|---|---|
bootConfig | @NonNull BootConfig | Required | A boot configuration. You can set values such as plugin key and position of the channel button. |
bootCallback | @Nullable BootCallback | null | A callback to be invoked when the boot completes. |
Use
sleep()
orshutdown()
when you want to use only a subset of the features or completely disconnect from the channel, respectively.
sleep
When the ChannelIO is in a sleep state, only the system push notification and event tracking via track
will remain active. Real-time chat and marketing popups will not be shown.
shutdown
Terminates the connection with the channel established by boot()
. shutdown()
disables all features including the system push notification and event tracking. If you wish to retain system push notification and event tracking capabilities, see sleep()
.
For example, if a user signs out from your service it is safe to shutdown()
to stop receiving a system push notification.
showChannelButton
Shows the Channel button to the Activities shown after the function is called.
The function takes effect even if it was called before boot()
completes. This is because the Channel Android SDK holds “global button visibility state” and boot()
does not reset the state.
hideChannelButton
Hides the Channel button.
showMessenger
Shows the messenger. If you have customized a channel button, you may use this function to show the messenger when the button is clicked.
Parameter | Type | Default Value | Description |
---|---|---|---|
activity | @NonNull Activity | Required | An Activity instance. |
hideMessenger
Hides the messenger.
openChat
Opens a chat. Note that the openChat
opens a specific chat while showMessenger
opens the messenger. You can not only open an existing chat but also create a new chat.
Parameter | Type | Default Value | Description |
---|---|---|---|
activity | @NonNull Activity | Required | An Activity instance. |
chatId | @Nullable String | Required | The chat ID to open. If chat ID is null or invalid, a new chat is created. |
message | @Nullable String | Required | A message filled when the chat opens. It takes effect only if chatId is null. |
openSupportBot (removed)
(removed)
Use
[openWorkflow](doc:android-channelio#openworkflow)
instead.The support bot is no longer supported and was replaced by workflow. The behavior of
openSupportBot
is the same as that ofopenWorkflow
.message
parameter is ignored.
Opens User chat to run a specific Support bot.
Parameter | Type | Default Value | Description |
---|---|---|---|
activity | @NonNull Activity | Required | An Activity instance. |
supportBotId | @Nullable String | Required | This is the support bot's ID. If ID is null or invalid, chat is closed. |
message | @Nullable String | Required | A message filled in input field. It takes effect only if supportBotId is valid. |
openWorkflow
Opens a user chat and starts the specified workflow.
openWorkflow
can only be executed when the workflow trigger is set to "When starting a chat via Channel Talk."- If a corresponded workflow with the provided
workflowId
is exists, it will be executed. ifworkflowId
is invalid, an error page is displayed. - If you don't pass
workflowId
, no action is taken.
parameter | type | required | description |
---|---|---|---|
workflowId | @Nullable String | X | The ID of workflow to start with. An error page will be shown if such workflow does not exist. |
track
Tracks an event of user activities. See event tracking for details.
Parameter | Type | Default Value | Description |
---|---|---|---|
eventName | @NonNull String | Required | An event name. |
eventProperty | @Nullable Map<String, Object> | null | An additional information of the event. |
Despite its Object type,
eventProperty
parameter should be a type which is convertible to the JSON format, or else it might lead to a crash. In particular, avoid passing an object which contains a circular reference.
updateUser
Updates user information.
Parameter | Type | Default Value | Description |
---|---|---|---|
userData | @NonNull UserData | Required | A user information to be updated. |
callback | @Nullable UserUpdateCallback | Required | A callback to be invoked when the update completes. |
addTags
Adds a tag for the user.
Parameter | Type | Default Value | Description |
---|---|---|---|
tags | vararg String | Required | Tags to be added. • The maximum length is 10. • Tag cannot be duplicated. • Tag is case-insensitive (converted to lowercase). • null, list including null, empty list, and empty string is not allowed. |
callback | @Nullable UserUpdateCallback | null | A callback to be invoked when the update completes. |
removeTags
Removes user’s tag. Non-existing tags are ignored.
Parameter | Type | Default Value | Description |
---|---|---|---|
tags | vararg String | Required | Tags to remove. • null, empty string, and list containing null or empty string is not allowed. |
callback | @Nullable UserUpdateCallback | null | A callback to be invoked when the update completes. |
setPage
Sets a page to show when an event is track
ed. The default page name is the name of currently active Activity. However there might be some cases where the default page name does not fit your use case, for example if you are using Single Activity Architecture with Navigation Component, you might want to set the page to provide helpful information.
You can also set a user chat profile.
Note that the page takes effect for events sent after the setPage
call. All events before the setPage
call will remain intact.
Be aware that the behavior of
setPage(null)
andresetPage()
differs. The former explicitly sets the page as null, while the latter resets the page to the default value.
Parameter | Type | Default Value | Description |
---|---|---|---|
page | @Nullable String | null | The page to be displayed in subsequent events. The page will be recorded as null if page parameter is null. |
profile | @Nullable Map<String, Object> | null | The user chat profile value. - When null is assigned to a specific field within the profile object, only the value of that field is cleared. - The user chat profile value is applied when a user chat is created. |
resetPage
Unset a page name and user chat profile set by setPage
. All page in events sent onwards will be recorded as an Activity name, which is a default page value.
hidePopup
Hides the Channel Popup on the global screen.
initPushToken
Notifies the Channel Talk SDK that the Firebase Cloud Messaging(FCM) token has changed.
Parameter | Type | Default Value | Description |
---|---|---|---|
token | @Nullable String | Required | A FCM token. |
isChannelPushNotification
Checks if the Channel Talk SDK is responsible for processing the push data.
Parameter | Type | Default Value | Description |
---|---|---|---|
payload | Map<String, String> | Required | A push data retrieved from FCM. Pass the value get by RemoteMessage#getData() . |
receivePushNotification
Shows a system push notification and notifies Channel Talk that a user received a push notification.
Parameter | Type | Default Value | Description |
---|---|---|---|
context | @NonNull Context | Required | A Context instance. |
payload | Map<String, String> | Required | A push data retrieved from FCM. Pass the value get by RemoteMessage#getData() . |
hasStoredPushNotification
Checks if there exists a push data passed to receivePushNotification
.
Parameter | Type | Default Value | Description |
---|---|---|---|
context | @NonNull Activity | Required | An Activity instance. |
openStoredPushNotification
Opens a chat according to the push data received by receivePushNotification
. Call this method at the Activity which is launched when the push notification is clicked.
isBooted
Checks if the latest boot
succeeded and shutdown
is not yet called.
setDebugMode
Toggles the debug mode. If true
, log messages will be shown.
Parameter | Type | Default Value | Description |
---|---|---|---|
flag | boolean | Required | A debug flag. |
setAppearance
Sets the appearance of the SDK.
Parameter | Type | Default Value | Description |
---|---|---|---|
appearance | Appearance | Required | • LIGHT: Light theme • DARK: Dark theme • SYSTEM: Follows the system theme. |
Updated 13 days ago