ChannelIO
initialize
Initializes the ChannelIO. It should be called before any other methods are used.
Parameter | Type | Default Value | Description |
---|---|---|---|
application | @NonNull Application | Required | An Application instance. |
attachView | boolean | true | If 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.
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 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 Talk. Use the bootCallback
parameter to define the task to be done after the boot completes.
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
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.
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 whereas showMessenger
shows 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. |
track
Tracks an event for the user. 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 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 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 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)
andresetPage()
is different.setPage(null)
literally sets page as null.
Parameter | Type | Default Value | Description |
---|---|---|---|
page | @Nullable String | null | A 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 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 about 1 month ago