initialize

The initialize function is responsible for initializing ChannelIO and should be invoked prior to any other methods of ChannelIO.

ParameterTypeDefault ValueDescription
application@NonNull ApplicationRequiredAn Application instance.
attachViewbooleantrueWhen 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.

ParameterTypeDefault ValueDescription
listener@Nullable ChannelPluginListenerRequiredA 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.

ParameterTypeDefault ValueDescription
bootConfig@NonNull BootConfigRequiredA boot configuration. You can set values such as plugin key and position of the channel button.
bootCallback@Nullable BootCallbacknullA callback to be invoked when the boot completes.

📘

Use sleep() or shutdown() 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.

ParameterTypeDefault ValueDescription
activity@NonNull ActivityRequiredAn 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.

ParameterTypeDefault ValueDescription
activity@NonNull ActivityRequiredAn Activity instance.
chatId@Nullable StringRequiredThe chat ID to open. If chat ID is null or invalid, a new chat is created.
message@Nullable StringRequiredA message filled when the chat opens. It takes effect only if chatId is null.

openSupportBot (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 of openWorkflow. message parameter is ignored.

Opens User chat to run a specific Support bot.

ParameterTypeDefault ValueDescription
activity@NonNull ActivityRequiredAn Activity instance.
supportBotId@Nullable StringRequiredThis is the support bot's ID. If ID is null or invalid, chat is closed.
message@Nullable StringRequiredA 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. if workflowId is invalid, an error page is displayed.
  • If you don't pass workflowId, no action is taken.
parametertyperequireddescription
workflowId@NullableStringXThe 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.

ParameterTypeDefault ValueDescription
eventName@NonNull StringRequiredAn event name.
eventProperty@Nullable Map<String, Object>nullAn 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.

ParameterTypeDefault ValueDescription
userData@NonNull UserDataRequiredA user information to be updated.
callback@Nullable UserUpdateCallbackRequiredA callback to be invoked when the update completes.

addTags

Adds a tag for the user.

ParameterTypeDefault ValueDescription
tagsvararg StringRequiredTags 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 UserUpdateCallbacknullA callback to be invoked when the update completes.

removeTags

Removes user’s tag. Non-existing tags are ignored.

ParameterTypeDefault ValueDescription
tagsvararg StringRequiredTags to remove.
• null, empty string, and list containing null or empty string is not allowed.
callback@Nullable UserUpdateCallbacknullA callback to be invoked when the update completes.

setPage

Sets a page to show when an event is tracked. 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) and resetPage() differs. The former explicitly sets the page as null, while the latter resets the page to the default value.

ParameterTypeDefault ValueDescription
page@Nullable StringnullThe page to be displayed in subsequent events.
The page will be recorded as null if page parameter is null.
profile@NullableMap<String, Object>nullThe 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.

ParameterTypeDefault ValueDescription
token@Nullable StringRequiredA FCM token.

isChannelPushNotification

Checks if the Channel Talk SDK is responsible for processing the push data.

ParameterTypeDefault ValueDescription
payloadMap<String, String>RequiredA 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.

ParameterTypeDefault ValueDescription
context@NonNull ContextRequiredA Context instance.
payloadMap<String, String>RequiredA push data retrieved from FCM.
Pass the value get by RemoteMessage#getData().

hasStoredPushNotification

Checks if there exists a push data passed to receivePushNotification.

ParameterTypeDefault ValueDescription
context@NonNull ActivityRequiredAn 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.

ParameterTypeDefault ValueDescription
flagbooleanRequiredA debug flag.

setAppearance

Sets the appearance of the SDK.

ParameterTypeDefault ValueDescription
appearanceAppearanceRequired• LIGHT: Light theme
• DARK: Dark theme
• SYSTEM: Follows the system theme.