ChannelIO

initialize

Initializes the ChannelIO. It should be called before any other methods are used.

ParameterTypeDefault ValueDescription
application@NonNull ApplicationRequiredAn Application instance.
attachViewbooleantrueIf true, the SDK will attach a view to show the channel button and marketing pop-ups for your activity. Use @SkipAttachChannelView to opt-out some activities from the view being attached.
If false, the view is not attached and you will have to use ChannelPluginListener to show an appropriate UI.

setListener

Sets a callback to be invoked when an event happens.

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 set by setListener. Short-cut for setListener(null).

boot

Prepares for channel-specific features such as showing a messenger and real-time chat. See how to use Channel.io. Use the bootCallback parameter to define the task to be done after the boot completes.

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

Only the system push notification and event tracking via track will be available after sleep. Real-time chat and marketing popups will not be shown.

shutdown

Removes the connection with the channel established by boot(). shutdown() disables all features including the system push notification and event tracking. To use only system push notification and event tracking, 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 whereas showMessenger shows 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.

track

Tracks an event for the user. 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 add.
• The maximum length is 10.
• Tag cannot be duplicated.
• Tag is case-insensitive (Tags are renamed to the lower-case.)
• 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 an Activity name. However in some cases where the default page 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.

Note that the page takes effect for events sent after the setPage call. All events before the setPage call will remain intact.

🚧

The behavior of the setPage(null) and resetPage() is different. setPage(null) literally sets page as null.

ParameterTypeDefault ValueDescription
page@Nullable StringnullA page to be shown in the event onwards.
The page will be recorded as null if page parameter is null. To set the Activity name as a page, use resetPage().

resetPage

Unset a page name set by setPage. All page in events sent onwards will be recorded as an Activity name, which is a default page value.

initPushToken

Notifies the Channel.io SDK that the Firebase Cloud Messaging(FCM) token has changed.

ParameterTypeDefault ValueDescription
token@Nullable StringRequiredA FCM token.

isChannelPushNotification

Checks if the Channel 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 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.