Methods

initialize

To allow user interaction, the Messaging SDK must be initiated. This API initializes the resources required by the SDK; all subsequent API calls. Except for the handlePushMessage, assume that the SDK has been initialized.

When the conversation screen is displayed, the server connection for messaging will be established. If a user session is already active and an additional SDK init call is made, it will be ignored and will not start an additional session.

initialize(@NotNull final Context context, @NotNull final MessagingConsumerProperties initProperties, @Nullable final IMessagingDelegate delegate, InitMessagingCallBack callback)
ParameterDescription
contextA context from the host app
initPropertiesAn object with all the properties needed to initialize the SDK
delegateClass that adheres to IMessagingDelegate
callbackInitMessagingCallback used to give results of the initialize call

showConversation

The showConversation API displays the messaging screen as a new activity with the conversation fragment. The consumer can then start or continue a conversation. The conversation screen is controlled entirely by the SDK.

This method returns a Boolean value to indicate success or failure in opening the messaging screen. If the operation is successful, this method returns true, else it returns false.

Initiating the conversation screen opens the XMPP connection to the ContactAtOnce Messaging Server.

public static boolean showConversation(@NotNull Context activity, @NotNull String referenceID, @NotNull String name, @Nullable String initialUserText)
ParameterDescription
activityThe calling activity
referenceIDMerchant’s account id in your system
nameName of merchant to be displayed
initialUserTextYour app generated initial message (optional)

getConversationFragment

The getConversationFragment method creates and returns the conversation fragment.

Note: This API does not show the actual screen, but only creates the fragment. Your implementation needs to handle when and how to show it.

public static Fragment getConversationFragment(String referenceID, String name, String initialUserText)
ParameterDescription
referenceIDMerchant’s account id in your system
nameName of merchant to be displayed
initialUserTextconsumerMessageYour app generated initial consumer message (optional)

registerForPushNotifications

public static void registerForPushNotifications(String gcmToken)
ParameterDescription
gcmTokenThe GCM Token. Usually used to pass the Google provided token. However, this parameter can contain any string value.

isMessagingNotification

Determines if a notification is a Messaging notification

public Boolean isMessagingNotification(Bundle data)
ParameterDescription
dataA Bundle that contains the notification data.

handlePush

All incoming push messages are received by the host app. The host app can choose to fully handle any push message and display a notification message, or partially handle it and allow the SDK to display the notification.

Handling the push message allows the host app to do the following:

  • Receive non-messaging related push messages.
  • Handle custom in-app alerts upon an incoming message.

Note: Whether the host app fully handles any push messages or partially, any messaging push message should be sent to the SDK using the handlePushMessage method.

public static void handlePushNotification(Context context, Bundle data)
ParameterDescription
contextA context from the host app.
dataA Bundle that contains the message. The bundle should hold a string with key named "message".

getSDKVersion

Returns the SDK version.

public static String getSDKVersion()

setCallback

Sets the SDK callback listener. The host app gets updates from the SDK using this callback listener. 

public static void setCallback(final MessagingCallback listener)
ParameterDescription
listenerA MessagingCallback implementation

removeCallBack

Removes the registered MessagingCallback.

public static void removeCallBack()