ICMessaging
This singleton is the main interface to the Webex Connect messaging system, it provides methods that facilitate incoming and outgoing messages, thread and topic management, message status, and connection control.
Return Type | Method |
---|---|
void | allowJavascriptInWebviews(boolean allow) Sets whether JavaScript execution is allowed within WebView instances that are created by the SDK. |
void | closeThread(ICThread thread, ICUpdateThreadCallback callback) Closes a conversation thread. |
void | connect() Used to establish a connection to receive In App Messages from the Webex Connect platform. |
void | createThread(String streamName, String threadTitle, ICCreateThreadCallback callback) - Removed |
void | createThread(ICThread thread, ICCreateThreadCallback callback) Creates a thread within the Webex Connect platform from the provided ICThreadobject. |
void | disconnect() Disconnects the In App Messaging connection between the app and Webex Connect platform. |
void | fetchMessages(String threadId, Date beforeDate, ICFetchMessagesCallback callback) Deprecated. |
void | fetchMessages(String threadId, Date beforeDate, int limit, ICFetchMessagesCallback callback) Fetches a list of messages that matches the specified criteria. |
void | deleteMessage(String messageTransactionId, ICDeleteMessageCallback callback) |
void | fetchThreads(Date beforeDate, ICFetchThreadsCallback callback) Deprecated. |
void | fetchThreads(Date beforeDate, int limit, ICFetchThreadsCallback callback) Fetches a list of threads that matches the specified criteria. |
void | fetchUnreadThreadCount(final ICFetchUnReadThreadCountCallback callback) Fetches the count of unread threads. |
void | fetchTopics(int offset, ICFetchTopicsCallback callback) Fetches the list of topics that are configured for the Webex Connect application. |
ICConnectionStatus | getConnectionStatus() Returns the current connection status between the SDK and Webex Connect platform. |
ICMessaging | getInstance() Returns the ICMessaging singleton instance, creating it if necessary. |
ICMessageStore | getMessageStore() Obtains the current message store instance, if set previously via a call to setMessageStore. |
boolean | isConnected() This method is used to verify whether the In App Messaging connection is currently connected to Webex Connect. |
boolean | isStarted() Used to determine whether ICMessaging has been started. |
void | publishMessage(ICMessage message, ICPublishMessageCallback callback) Publishes a message to the Webex Connect platform. |
void | registerListener(ICMessagingListener listener) Registers an ICMessagingListener to listen for incoming messages and connection status updates. |
void | setMessageAsRead(String transactionId, ICSetMessageStatusCallback callback) Updates the status of a message to Read. |
void | setMessagesAsRead(String[] transactionIds, ICSetMessageStatusCallback callback) Sets the status for multiple messages to Read. |
void | setMessageStore(ICMessageStore store) Sets the ICMessageStore implementation that the SDK will use to persist In-App Message data. Passing a null value will remove any previously set store and disable message persistence. |
void | shutdown() Deprecated - Use shutdown(ICShutdownCallback) instead. |
void | shutdown(ICShutdownCallback callback) It provides a means to shut down the messaging module and perform the cleanup. There is normally no need to call this method. |
void | subscribeTopic(String topic, ICSubscribeTopicCallback callback) Subscribes the current user to a topic. After successful completion, the SDK will receive any future messages that are published to the topic. |
void | unregisterListener(ICMessagingListener listener) Unregisters a previously registered ICMessagingListener, in order to stop listening for incoming messages and connection status updates. |
void | unsubscribeTopic(String topic, ICUnsubscribeTopicCallback callback) Unsubscribes the current user from a topic. After successful completion, the user will no longer receive future messages sent to the topic. |
void | updateThread(ICThread thread, ICUpdateThreadCallback callback) Updates a thread within the remote Webex Connect platform. |
void | processPushData To handle push message received from Webex Connect platform. |
void | isConnectPushData This helper method returns whether the message is from the Webex Connect platform or not. |
void | processPushToken To handle the new push registration token. |
String | getPushToken Gets the push token of the current device |
void | addPushTokenListener Adds an object which implements the ICPushTokenListener interface to listen for updated token |
void | removePushTokenListener Removes a previously added object which implements the ICPushTokenListener interface, in order to stop listening for updated token |
allowJavascriptInWebviews
Sets whether JavaScript execution is allowed within WebView instances that are created by the SDK. The default value is false.
Syntax: void allowJavascriptInWebviews(boolean flag)
Parameters:
Parameter | Type | Description |
---|---|---|
flag | Boolean | True if WebView Javascript execution should be allowed. |
closeThread
Closes a conversation thread.
Syntax: void closeThread(final ICThread thread, final ICUpdateThreadCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
thread | ICThread | A valid instance for the thread that should be closed. |
callback | ICUpdateThreadCallback | Receives the result of the close operation. If an error occurs then the exception parameter will not be null. |
connect
Once the RT feature is enabled in the app asset created on Webex Connect and user registration is done, the App Developer can establish a connection between the app and Webex Connect platform by calling the connect method appropriately. This enables the messages sent from Webex Connect to be received on the app. When the application is running in the background, SDK is disconnected from Webex Connect. While in the disconnected state, incoming In-App messages are not received, however when the application comes to foreground again, SDK will establish a connection with the Webex Connect platform and allow messages to be received.
Webex Connect is used to establish a connection to receive In-App Messages from the Webex Connect platform.
Connection status events are notified through ICMessagingReceiver.onConnectionStatusChanged and ICMessagingListener.onConnectionStatusChanged.
Throws an
ICException
if a user is not registered with Webex Connect or if In-App Messaging is not enabled.
Syntax: void connect() throws ICException
Example:
ICMessaging messaging = ICMessaging.getInstance();
try
{
messaging.connect();
}
catch (ICException e)
{
Log.e("Connect", e.toString());
}
createThread
Deprecated in v2.7.0, use createThread(ICThread thread, ICCreateThreadCallback callback) instead.
Creates a thread based on the provided streamName
and threadTitle
.
Syntax: void createThread(final String streamName, final String threadTitle, final ICCreateThreadCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
streamName | String | Name of the stream. |
threadTitle | String | The thread title. |
callback | ICCreateThreadCallback | Invoked to report the result of the operation. |
Example:
ICMessaging.getInstance().createThread(streamName, threadTitle, new ICCreateThreadCallback()
{
@Override
public void onCreateThreadComplete(final ICThread thread, final ICException exception)
{
if (exception != null)
{
Log.e("CreateThread", "createdThread failed! Reason:" + exception.toString());
}
else
{
Log.d("CreateThread ", "createdThread succeeded!");
}
}
});
createThread
Creates a thread within the Webex Connect platform from the provided ICThread object.
Syntax: void createThread(final ICThread thread, final ICCreateThreadCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
thread | ICThread | A valid thread instance that should be created within the remote Webex Connect platform. |
callback | ICCreateThreadCallback | Invoked to report the result of the operation. |
Always check that the createThread method is successful before using the thread instance further. On successful completion, the thread will be populated with a valid identifier.
Example:
ICThread thread = new ICThread();
thread.setTitle("MyTitle");
thread.setCategory("MyCategory");
ICMessaging.getInstance().createThread(thread, new ICCreateThreadCallback()
{
@Override
public void onCreateThreadComplete(final ICThread thread, final ICException exception)
{
if (exception != null)
{
Log.e("CreateThread", "createdThread failed! Reason:" + exception.toString());
}
else
{
Log.d("CreateThread ", " createdThread succeeded!");
}
}
});
disconnect
Disconnects the In-App Messaging connection between the app and the Webex Connect platform. If there is no active connection, then this method fails silently.
When the disconnection completes, the event is notified through ICMessagingReceiver.onConnectionStatusChanged and ICMessagingListener.onConnectionStatusChanged.
Throws an
ICException
if the device is not registered with Webex Connect or if the In-App Messaging feature is not enabled.
Syntax: void disconnect() throws ICException
Example:
try
{
ICMessaging.getInstance().disconnect();
}
catch (ICException e)
{
Log.e("Disconnect", e.toString());
}
fetchMessages
Deprecated, use fetchMessages(String threadId, Date beforeDate, int limit, ICFetchMessagesCallback callback)
Fetches a list of messages that matches the specified criteria. The results are notified through the ICFetchMessagesCallback
callback.
Syntax: fetchMessages(String threadId, Date beforeDate, ICFetchMessagesCallback callback)
fetchMessages
Fetches a list of messages that matches the specified criteria.
Results are notified through ICFetchMessagesCallback and are ordered from newest to oldest.
Syntax: fetchMessages(String threadId, Date beforeDate, int limit, ICFetchMessagesCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
threadId | String | Specifies the value of ThreadId. |
beforeDate | Date | Filters the list of returned messages to contain only messages where the submittedAt date is before the passed date. This value is optional; if null is passed, the SDK will use the current Date and Time to fetch recent messages. |
limit | int | Limits the number of messages that are fetched. |
callback | ICFetchMessagesCallback | Invoked to report the result of the operation. |
Example:
ICMessaging.getInstance().fetchMessages(threadId, beforeDate, limit, new ICFetchMessagesCallback()
{
@Override
public void onFetchMessagesComplete(final ICMessage[] messages, final boolean hasMoreData, final ICException exception)
{
if (exception != null)
{
Log.e("fetchMessages", "fetchMessages failed! Reason:" + exception.toString());
return;
}
Log.e("fetchMessages", "fetchMessages success:");
}
});
deleteMessage
Invoke deleteMessage to delete the given message transaction id from the Webex Connect platform.
The result of the operation is reported through ICDeleteMessageCallback.
Syntax: deleteMessage(String messageTransactionId, ICDeleteMessageCallback callback)
Parameters:
Paremeter | Type | Description |
---|---|---|
messageTransactionId | String | The transaction id of the message. See ICMessage.getTransactionId() . |
callback | ICDeleteMessageCallback | Null if the operation succeeded. |
Example:
String messageTransactionId = message.getTransactionId();
ICMessaging.getInstance().deleteMessage(messageTransactionId, new ICDeleteMessageCallback() {
@Override
public void onDeleteMessageComplete(final String messageTransactionId, final ICException exception) {
if (exception != null) {
Log.e("DeleteMessage", exception.getLocalizedMessage(), exception);
return;
}
Log.d("DeleteMessage", "Message deleted successfully, transactionId: " + messageTransactionId);
}
});
Callbacks
Below are the classes that have been created to implement for this Release:
- ICPublishEventCallback
- ICDeleteMessageCallback
ICPublishEventCallback
Used to receive the result of publishing events operations made via IMIconnect.publishEvent
Return Type | Method |
---|---|
void | onPublishEventComplete(Bundle bundle, ICException exception) |
onPublishEventComplete
Invoked to report the result of publishing event operations. If the operation succeeds the exception parameter will be null.
Syntax: void onPublishEventComplete(Bundle bundle, ICException exception)
Parameters:
Parameter | Type | Description |
---|---|---|
bundle | Bundle | Reserved for future use. |
exception | ICException | Null if the operation succeeded. |
ICDeleteMessageCallback
Used to receive the result of delele message operations made via ICMessaging.deleteMessage
Return Type | Method |
---|---|
void | onDeleteMessageComplete(String messageTransactionId, ICException exception) |
onDeleteMessageComplete
Invoked to report the result of delete message operations. If the operation succeeds the exception parameter will be null.
Syntax: void onDeleteMessageComplete(String messageTransactionId, ICException exception)
Parameters:
Parameter | Type | Description |
---|---|---|
messageTransactionId | String | Message’s transaction id |
exception | ICException | Null if the operation succeeded. |
getServerDomain
Returns the server domain.
Syntax: String getServerDomain()
Return Value: Returns the server domain.
fetchStreams
Removed in v2.7.0. - Streams are no longer used by the Webex Connect platform, messages are now routed to services based on app associations.
Fetches the list of streams that are associated with the Webex Connect application.
Syntax: fetchStreams(final ICFetchStreamsCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
callback | ICFetchStreamsCallback | Invoked to report the result of the operation. |
ICMessaging.getInstance().fetchStreams(new ICFetchStreamsCallback()
{
@Override
public void onFetchStreamsComplete(final ICStream[] streams, final ICException exception)
{
if (exception != null)
{
Log.e("fetchStreams", "fetchStreams failed! Reason:" + exception.toString());
return;
}
Log.e("fetchStreams", "fetchStreams success:");
}
});
fetchThreads
Deprecated - Use fetchThreads(Date, int, ICFetchThreadsCallback) instead.
Fetches a list of threads that matches the specified criteria.
Results are reported through the ICFetchThreadsCallback
callback and are ordered newest to oldest.
Syntax: fetchThreads (int limit, ICFetchThreadsCallback callback)
fetchThreads
Fetches a list of threads that matches the specified criteria.
Results are reported through ICFetchThreadsCallback and are ordered newest to oldest.
Syntax: fetchThreads (Date beforeDate, int limit, ICFetchThreadsCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
beforeDate | date | Constrains the results to threads that have been created before the provided date. |
limit | int | Limits the number of threads that are fetched. |
callback | ICFetchThreadsCallback | Invoked to report the result of the operation. |
Example:
ICMessaging.getInstance().fetchThreads(beforeDate,10, new ICFetchThreadsCallback()
{
@Override
public void onFetchThreadsComplete(final ICThread[] threads, final boolean hasMoreData, final ICException exception)
{
if (exception != null)
{
Log.e("fetchThreads", "fetchThreads failed! Reason:" + exception.toString());
return;
}
Log.e("fetchThreads", "fetchThreads success:");
}
});
fetchUnreadThreadCount
Fetches the count of unread threads.
Syntax: fetchUnreadThreadCount(final ICFetchUnReadThreadCountCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
callback | ICFetchUnReadThreadCountCallback | The callback is to be invoked with the count of unread threads. |
fetchTopics
Fetches the list of topics that are configured for the Webex Connect application.
Syntax: fetchTopics(int offset, final ICFetchTopicsCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
offset | Integer | Filters the topics returned to start from the given offset. |
callback | ICFetchTopicsCallback | Invoked to report the result of the operation. |
When the topic list is large, Webex Connect will return a subset of the results. Use the offset parameter to fetch subsequent results.
Hint: Use the 'hasMoreData' parameter of the ICFetchTopicsCallback.onFetchTopicsComplete method to determine when there is additional data to fetch. Keep a track of your fetched record count to use as the offset to the next call.
Example:
ICMessaging.getInstance().fetchTopics(0, new ICFetchTopicsCallback()
{
@Override
public void onFetchTopicsComplete(final ICTopic[] topics, final boolean hasMoreData, final ICException exception)
{
if (exception != null)
{
Log.e("fetchTopics", "fetchTopics failed! Reason:" + exception.toString());
return;
}
Log.e("fetchTopics", "fetchTopics success:");
if (hasMoreData)
{
//Fetch more, use accumulation of topics.length for offset
//i.e. offset += topics.length;
}
}
});
getConnectionStatus
Returns the current connection status between the SDK and Webex Connect platform.
Syntax: ICConnectionStatus getConnectionStatus()
Return Value: Returns the current connection status between the SDK and the Webex Connect platform.
getInstance
Returns the ICMessaging
singleton instance, creating it if necessary.
Syntax: ICMessaging getInstance()
Return Value:
Returns the ICMessaging
singleton instance.
getMessageStore
Obtains the current message store instance, if set previously via a call to setMessageStore(ICMessageStore).
Syntax: ICMessageStore getMessageStore()
Return Value: The ICMessageStore instance, if set, otherwise null.
isConnected
This method is used to verify whether the In App Messaging connection is currently connected to Webex Connect. This is a convenience method for getConnectionStatus() == ICConnectionStatus.Connected
.
Syntax: boolean isConnected()
Return Value: Returns _true _if the Live Chat / In-App Messaging connection is currently connected.
isStarted
Used to determine whether ICMessaging has been started.
Syntax: static boolean isStarted()
Return Value: Returns true if ICMessaging has been started, otherwise false.
The ICMessaging instance is started automatically when the
getInstance
method is called.
publishMessage
Publishes a message to the Webex Connect platform.
The ICMessage passed to this method must contain a valid ICThread instance.
Results of the operation are reported through ICPublishMessageCallback.
Syntax: void publishMessage(ICMessage message, ICPublishMessageCallback callback)
Parameters:
Parameters | Type | Description |
---|---|---|
message | ICMessage | The message to send to the Webex Connect platform. |
callback | ICPublishMessageCallback | Invoked to report the result of the operation. |
Example:
ICMessage message = new ICMessage();
message.setMessage("Test message");
message.setThread(yourThreadObj);
ICMessaging.getInstance().publishMessage(message, new ICPublishMessageCallback()
{
@Override
public void onPublishMessageComplete(final ICMessage message, final ICException exception)
{
if (exception != null)
{
Log.e("PublishMessage", exception.toString());
}
else
{
Log.d("PublishMessage", "Published Successfully");
}
}
});
registerListener
Registers an ICMessagingListener to listen for incoming messages and connection status updates.
Syntax: void registerListener(ICMessagingListener listener)
Parameters | Type | Description |
---|---|---|
listener | ICMessagingListener | Listener for receiving incoming messages and connection status updates |
setMessageAsRead
Updates the status of a message to Read.
The result of the operation is reported through ICSetMessageStatusCallback.
Syntax: void setMessageAsRead(String transactionId, ICSetMessageStatusCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
transactionId | String | The transaction id of the message whose status should be set as read. See ICMessage.getTransactionId() |
callback | ICSetMessageStatusCallback | Invoked to report the result of the operation. |
Example:
String messageTransactionId = message.getTransactionId();
ICMessaging.getInstance().setMessageAsRead(messageTransactionId, new ICSetMessageStatusCallback()
{
@Override
public void onSetMessageStatusComplete(final String[] messageTransactionIds, final ICException exception)
{
if (exception != null)
{
Log.e("MessageAsRead", exception.toString());
}
else
{
Log.d("MessageAsRead", "Updated Successfully");
}
}
});
setMessagesAsRead
Sets the status for multiple messages to Read.
The result of the operation is reported through [ICSetMessageStatusCallback]((https://developers.imiconnect.io/docs/callbacks-1#icsetmessagestatuscallback).
Syntax: void setMessagesAsRead(String[] transactionIds, ICSetMessageStatusCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
transactionIds | String [] | An array of message transaction ids whose status should be set to Read. |
callback | ICSetMessageStatusCallback | Invoked to report the result of the operation. |
Example:
String[] messageTransactionIds = new String[] { "id1", "id2" };
ICMessaging.getInstance().setMessagesAsRead(messageTransactionIds, new ICSetMessageStatusCallback()
{
@Override
public void onSetMessageStatusComplete(final String[] messageTransactionIds, final ICException exception)
{
if (exception != null)
{
Log.e("MessagesAsRead", exception.toString());
}
else
{
Log.d("MessagesAsRead", "Updated Sucessfully");
}
}
});
setMessageStore
Sets the ICMessageStore implementation that the SDK will use to persist In-App Message data. Passing a null value will remove any previously set store and disable message persistence.
Syntax: void setMessageStore(ICMessageStore messageStore)
Parameters:
Parameter | Type | Description |
---|---|---|
messageStore | ICMessageStore | Pass a valid ICMessageStore implementation to enable In App Message persistence. Pass null to remove any existing store and disable message persistence. |
shutdown
Deprecated - Use shutdown(ICShutdownCallback) instead.
It provides a means to shut down the messaging module and perform the cleanup. There is normally no need to call this method.
Syntax: void shutdown()
shutdown
It provides a means to shut down the messaging module and perform the cleanup. There is normally no need to call this method.
Syntax: void shutdown(ICShutdownCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
callback | ICShutdownCallback | Invoked when shutdown is complete. |
Example:
ICMessaging.shutdown(new ICShutdownCallback()
{
@Override
public void onShutdownComplete()
{
Log.d("ICMessaging", "Shutdown Completed");
}
});
subscribeTopic
Subscribes the current user to a topic. After successful completion, the SDK will receive any future messages that are published to the topic.
The result of the operation is reported through ICSubscribeTopicCallback.
Syntax: void subscribeTopic(String topicId, ICSubscribeTopicCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
topicId | String | The topic to which the user should be subscribed. |
callback | ICSubscribeTopicCallback | Invoked to report the success of the operation. |
Example:
String topic = "<your topicId>";
ICMessaging.getInstance().subscribeTopic(topicId, new ICSubscribeTopicCallback()
{
@Override
public void onSubscribeTopicComplete(final String topicId, final ICException exception)
{
if (exception != null)
{
Log.e("SubscribeTopic", exception.toString());
}
else
{
Log.d("SubscribeTopic", "Subscribed Successfully");
}
}
});
unregisterListener
Unregisters a previously registered ICMessagingListener, in order to stop listening for incoming messages and connection status updates.
Syntax: void unregisterListener(ICMessagingListener listener)
Parameters | Type | Description |
---|---|---|
listener | ICMessagingListener | The listener that should be unregistered. If the listener was not previously registered the method will fail silently. |
unsubscribeTopic
Unsubscribes the current user from a topic. After successful completion, the user will no longer receive future messages sent to the topic.
The result of the operation are reported through ICUnsubscribeTopicCallback.
Syntax: void unsubscribeTopic(String topicId, ICUnsubscribeTopicCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
topicId | String | The topic from which the user should be unsubscribed. |
callback | ICUnsubscribeTopicCallback | Invoked to report the result of the operation. |
Example:
String topicId = "<your topicId>";
ICMessaging.getInstance().unsubscribeTopic(topicId, new ICUnsubscribeTopicCallback()
{
@Override
public void onUnsubscribeTopicComplete(final String topicId, final ICException exception)
{
if (exception != null)
{
Log.e("UnsubscribeTopic", exception.toString());
}
else
{
Log.d("UnsubscribeTopic", "Unsubscribed Successfully");
}
}
});
updateThread
Updates a thread within the remote Webex Connect platform.
Syntax: void updateThread(ICThread thread, final ICUpdateThreadCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
thread | ICThread | The thread instance whose data will be sent to the Webex Connect platform. |
callback | ICUpdateThreadCallback | Invoked to notify the result of the operation. If an error occurs then the exception parameter will not be null. |
processPushData
This method is called to handle push message received from Webex Connect platform.
Syntax: void processPushData(Map<String,String> data) throws ICException
Parameters:
Parameter | Type | Description |
---|---|---|
data | Map<String,String> | The message data map. |
Note
This method call required only if application developer implements their own FirebaseMessagingService and requires connect SDK to process the push message received from connect platform.
try
{
ICMessaging.getInstance().processPushData(remoteMessage.getData());
}
catch (ICException exception)
{
Log.e("processPushData", exception.getLocalizedMessage(), exception);
}
isConnectPushData
This helper method returns whether the message is from the Webex Connect platform or not.
Syntax: void isConnectPushData(Map<String,String> data)
Parameters:
Parameter | Type | Description |
---|---|---|
data | Map<String,String> | The message data map. |
Return Value: Returns true if the message is from Webex Connect platform false otherwise.
processPushToken
This method processes the received Push token from the application.
Syntax: public static void processPushToken(context, token) throws ICException
Throws an ICException if a user is not registered with Webex Connect or if Push feature is not enabled.
Parameters:
Parameter | Type | Description |
---|---|---|
context | Context | Specifies the Android context. |
token | String | The token string to be processed. |
try {
ICMessaging.getInstance().processPushToken(getApplicationContext(), token);
} catch (ICException e) {
Log.e("processPushToken", e.getLocalizedMessage(), e);
}
Note:
This method call required only if application developer implements their own FirebaseMessagingService and requires to receive push messages from the Webex Connect platform.
processPushToken (Deprecated)
This method is called to handle the new push registration token.
Syntax: public void processPushToken() throws ICException
Example:
try
{
ICMessaging.getInstance().processPushToken();
}
catch (ICException e)
{
Log.e("processPushToken", exception.getLocalizedMessage(), exception);
}
This method call is required only if application developer implements their own FirebaseMessagingService and requires to receive push messages from connect platform.
getPushToken
This method is called to gets the current device push token.
Syntax: public static String getPushToken()
String pushToken = ICMessaging.getPushToken();
addPushTokenListener
This method allows you to add an object which implements the ICPushTokenListener interface to listen for updated token.
Syntax: public static void addPushTokenListener(final ICPushTokenListener listener)
Parameter | Type | Decription |
---|---|---|
listener | ICPushTokenListener | Push token listener |
ICMessaging.addPushTokenListener(new ICPushTokenListener()
{
@Override
public void onNewPushToken(final String pushToken)
{
Log.d(TAG, "onNewPushToken(): " + pushToken);
}
});
removePushTokenListener
This method allows the developer to remove a previously added object which implements the ICPushTokenListener interface, in order to stop listening for updated token.
Syntax: public static void removePushTokenListener(final ICPushTokenListener listener)
Parameter | Type | Decription |
---|---|---|
listener | ICPushTokenListener | Push token listener |
RequestNotificationPermission
Requests the system notification permission prompt to enable notifications display on Android 13 devices. This permission required for apps that target Android API level 33 to allow an app to post notifications
Syntax: public void requestNotificationPermission(boolean openSettings)
Parameter | Description |
---|---|
openSettings | True to display a dialog to direct users to the App's notification settings if they have declined permission before |
RequestNotificationPermission
Requests the system notification permission prompt to enable notifications display on Android 13 devices. This permission required for apps that target Android API level 33 to allow an app to post notifications
Syntax: public void requestNotificationPermission(boolean openSettings, ICNotificationPermissionCallBack callback)
Parameters:
Parameters | Description |
---|---|
openSettings | True to display a dialog to direct users to the App's notification settings if they have declined permission before. |
callback | Invoked when the user accepts or declines the notification permission prompt. |
sendClickedEvent
This method sends a click event to the messaging manager for the selected button and with the transaction id.
Syntax: void sendClickedEvent(final String messageTransactionId, final ICButton icButton, final ICSetMessageStatusCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
messageTransactionId | String | The transactionId of the message |
icButton | ICButton | The interacted ICButton for which an ICMessage is created |
fetchThread
This method fetches the thread object for the threadID. Results are reported through ICFetchThreadCallback.
Syntax: public void fetchThread(final String threadId, final ICFetchThreadCallback callback)
Parameters:
Parameter | Type | Description |
---|---|---|
threadId | String | Specifies the value of ThreadId. |
callback | ICFetchThreadCallback | Invoked to report the result of the operation. |
Sample Code:
ICMessaging.getInstance().fetchThread(threadId, new ICFetchThreadCallback()
{
@Override
public void onFetchThreadComplete(ICThread thread, ICException exception) {
if (exception != null)
{
Log.e("fetchThread", "fetchThread failed! Reason:" + exception.toString());
return;
}
Log.d("fetchThread", "fetchThread success:");
}
});
Updated about 1 month ago