Package com.avaya.core

## Class AvMessagingSdk

- java.lang.Object
- - com.avaya.core.AvMessagingSdk

-     public final class AvMessagingSdk
      extends java.lang.Object

  AvMessagingSdk Entry Point

- - ### Method Summary

    All Methods Static Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static void` | `addConversationUiDelegate​(int key, ConversationDelegate conversationUiDelegate)` | Add a `ConversationDelegate` used by the avMessagingSdk-ui package
    `static void` | `createConversation​(java.lang.String name, java.lang.String description, java.lang.String iconUrl, java.lang.String avatarUrl, java.util.List<Message> messages, java.util.Map<java.lang.String,​java.lang.Object> metadata, AvMessagingSdkCallback<java.lang.Void> callback)` | Create a conversation for the current user.
    `static void` | `destroy()` | Terminate the AvMessagingSdk facilities.
    `static AvMessagingSdkConnectionStatus` | `getAvMessagingSdkConnectionStatus()` | Accessor method for the current `AvMessagingSdkConnectionStatus`, or null if `init(Application, Settings, AvMessagingSdkCallback)` hasn't been called yet.
    `static Config` | `getConfig()` | Accessor method for the currently connected app configuration.
    `static Conversation` | `getConversation()` | Accessor method for the current conversation.
    `static void` | `getConversationById​(java.lang.String conversationId, AvMessagingSdkCallback<Conversation> callback)` | Get a `Conversation` by its ID.
    `static ConversationDelegate` | `getConversationDelegate()` | Gets the delegate set via `setConversationDelegate(ConversationDelegate)`.
    `static java.util.Collection<ConversationDelegate>` | `getConversationDelegates()` | Gets the collection of `ConversationDelegate` that have been set on the SDK as a `SortedMap` where the integrator defined delegate will appear before the delegate used to notify the AvMessagingSdk UI
    `static void` | `getConversationsList​(AvMessagingSdkCallback<java.util.List<Conversation>> callback)` | Get the list of the 10 most recently active `Conversation`s for the current user, sorted from most recently updated to last.
    `static ConversationDelegate` | `getConversationUiDelegate​(int key)` | Gets a delegate set via `addConversationUiDelegate(int key, ConversationDelegate)` using the key.
    `static ConversationViewDelegate` | `getConversationViewDelegate()` | Gets the delegate set via `setConversationViewDelegate(ConversationViewDelegate)`.
    `static java.lang.String` | `getFirebaseCloudMessagingProjectId()` | Accessor method to get the Firebase Cloud Messaging project id that was linked to the application via the Web portal.
    `static InitializationStatus` | `getInitializationStatus()` | Accessor method for the current Initialization status.
    `static LoginResult` | `getLastLoginResult()` | Accessor for last known `LoginResult` or `null` if the user is anonymous or `init(Application, Settings, AvMessagingSdkCallback)` hasn't been called
    `static MessageModifierDelegate` | `getMessageModifierDelegate()` | Gets the delegate set via `setMessageModifierDelegate(MessageModifierDelegate)`.
    `static void` | `getMoreConversationsList​(AvMessagingSdkCallback<java.util.List<Conversation>> callback)` | Get the list of the 10 more recently active `Conversation`s for the current user, sorted from most recently updated to last.
    `static Settings` | `getSettings()` | Accessor method for the SDK settings.
    `static boolean` | `hasMoreConversations()` | Accessor method for knowing if there are more conversations to be fetched or not.
    `static void` | `init​(android.app.Application application)` | Initializes AvMessagingSdk without settings.
    `static void` | `init​(android.app.Application application, Settings settings, AvMessagingSdkCallback<InitializationStatus> callback)` | Initialize the AvMessagingSdk SDK with the provided settings.
    `static void` | `loadConversation​(java.lang.String conversationId, AvMessagingSdkCallback<Conversation> callback)` | Loads a conversation by its ID and sets it as the active conversation for the current session.
    `static void` | `login​(java.lang.String externalId, java.lang.String jwt, AvMessagingSdkCallback<LoginResult> callback)` | Logs in a new AvMessagingSdk user.
    `static void` | `logout​(AvMessagingSdkCallback<LogoutResult> callback)` | Logs out the current user.
    `static void` | `setConversationDelegate​(ConversationDelegate conversationDelegate)` | Sets the `ConversationDelegate`
    `static void` | `setConversationInputDisplayed​(boolean displayed)` | Toggles whether the input bar is displayed on the conversation view.
    `static void` | `setConversationViewDelegate​(ConversationViewDelegate conversationViewDelegate)` | Sets the `ConversationViewDelegate`
    `static void` | `setFirebaseCloudMessagingToken​(java.lang.String token)` | Method used to register the Firebase Cloud Messaging token to AvMessagingSdk
    `static void` | `setFirebaseCloudMessagingToken​(java.lang.String token, AvMessagingSdkCallback<LoginResult> callback)` | Method used to register the Firebase Cloud Messaging token to AvMessagingSdk
    `static void` | `setMessageModifierDelegate​(MessageModifierDelegate messageModifierDelegate)` | Sets the `MessageModifierDelegate`
    `static void` | `startConversation​(AvMessagingSdkCallback<java.lang.Void> callback)` | Deprecated.
    `static void` | `updateConversationById​(java.lang.String conversationId, java.lang.String name, java.lang.String description, java.lang.String iconUrl, java.util.Map<java.lang.String,​java.lang.Object> metadata, AvMessagingSdkCallback<Conversation> callback)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### init

          public static void init​(android.app.Application application)

      Initializes AvMessagingSdk without settings. Use this only if you intend to call `init(Application, Settings, AvMessagingSdkCallback)` outside of an `Application` class

      This may only be called from `Application.onCreate()`.

      Parameters:
        `application` - The `Application`

    - #### init

          public static void init​(android.app.Application application,
                                  Settings settings,
                                  AvMessagingSdkCallback<InitializationStatus> callback)

      Initialize the AvMessagingSdk SDK with the provided settings.

      This may only be called from `Application.onCreate()`, unless `init(Application)` was called there.

      Use `AvMessagingSdk.getSettings()` to retrieve and modify the given settings object.

      Parameters:
        `application` - The `Application`
        `settings` - The `Settings` to use
        `callback` - An optional `AvMessagingSdkCallback` instance to be notified of the result. Call `AvMessagingSdkCallback.Response.getData()` to check the `InitializationStatus`
      See Also:
        `Settings`, `AvMessagingSdkCallback`, `AvMessagingSdkCallback.Response`, `InitializationStatus`

    - #### login

          public static void login​(java.lang.String externalId,
                                   java.lang.String jwt,
                                   AvMessagingSdkCallback<LoginResult> callback)

      Logs in a new AvMessagingSdk user.

      You can either use this method to transition from logged out state to logged in, refresh the token of the existing logged in user or to switch the currently logged in user to a different one. You may not call login while the conversation screen is shown unless it is being called for the user already logged in. Doing so will result in a no-op. `init(Application, Settings, AvMessagingSdkCallback)` must have been called prior to calling login.

      Parameters:
        `externalId` - The distinct id of the user to login. Must not be null.
        `jwt` - jwt used to prove the origin of the login request. Must not be null.
        `callback` - An optional `AvMessagingSdkCallback` instance to be notified of the result. Call `AvMessagingSdkCallback.Response.getData()` to check the `LoginResult`
      See Also:
        `AvMessagingSdkCallback`, `AvMessagingSdkCallback.Response`, `LoginResult`

    - #### logout

          public static void logout​(AvMessagingSdkCallback<LogoutResult> callback)

      Logs out the current user.

      Calling this method while in anonymous state has no effect. You may not call logout while the conversation screen is shown. Doing so will result in a no-op.

      Parameters:
        `callback` - An optional `AvMessagingSdkCallback` instance to be notified of the result. Call `AvMessagingSdkCallback.Response.getData()` to check the `LogoutResult`
      See Also:
        `AvMessagingSdkCallback`, `AvMessagingSdkCallback.Response`, `LogoutResult`

    - #### startConversation

          @Deprecated
          public static void startConversation​(AvMessagingSdkCallback<java.lang.Void> callback)

      Deprecated.
      See Also:
        `This method has been Deprecated. Use instead`

    - #### createConversation

          public static void createConversation​(java.lang.String name,
                                                java.lang.String description,
                                                java.lang.String iconUrl,
                                                java.lang.String avatarUrl,
                                                java.util.List<Message> messages,
                                                java.util.Map<java.lang.String,​java.lang.Object> metadata,
                                                AvMessagingSdkCallback<java.lang.Void> callback)

      Create a conversation for the current user.

      Creates a user and conversation on the server, allowing the business to reach out proactively to the user via the public API.

      Creating a conversation via this method will count as a monthly active user (MAU) whether messages are exchanged or not, which may incur cost based on your plan. It is strongly recommended to only call this method in the case where a message is likely to be sent.

      A List containing one `Message` can be passed in as well to add messages when the conversation is created. Only messages of type text are supported. Any other message type will cause an error.

      This method is called automatically when starting a conversation via the `Conversation.sendMessage(Message)` or `Conversation.uploadImage(Message, AvMessagingSdkCallback)` methods, or when a user sends a message via the conversation activity.

      Parameters:
        `name` - A user-friendly name to label the conversation in the list (max length 100).
        `description` - A string describing the purpose of the conversation (max length 100).
        `messages` - A `List` of text `Message` to be sent when the conversation is created. Only messages of type text are supported. Any other message type will cause an error. The List can only contain one message.
        `iconUrl` - An iconUrl to display in the conversation list. It should be a valid icon URL.
        `avatarUrl` - An avatarUrl to display as the avatar
        `callback` - An optional `AvMessagingSdkCallback` instance to be notified of the result.
        `metadata` - The conversation metadata (JSON Object)
      See Also:
        `AvMessagingSdkCallback`, `AvMessagingSdkCallback.Response`

    - #### loadConversation

          public static void loadConversation​(java.lang.String conversationId,
                                              AvMessagingSdkCallback<Conversation> callback)

      Loads a conversation by its ID and sets it as the active conversation for the current session.

      When called, subscribes the current device for push notifications on the passed conversationId, and sets the SDK to send and receive messages for that conversation going forward. Does not unsubscribe for notification on previously loaded conversations.

      The provided callback contain the conversation that was loaded if successful.

      If the conversation is already set to the passed id, this call will just return the currently loaded conversation.

      Parameters:
        `conversationId` - The conversationId to set.
        `callback` - An optional `AvMessagingSdkCallback` instance to be notified of the result.
      See Also:
        `AvMessagingSdkCallback`, `AvMessagingSdkCallback.Response`

    - #### updateConversationById

          public static void updateConversationById​(java.lang.String conversationId,
                                                    java.lang.String name,
                                                    java.lang.String description,
                                                    java.lang.String iconUrl,
                                                    java.util.Map<java.lang.String,​java.lang.Object> metadata,
                                                    AvMessagingSdkCallback<Conversation> callback)

      Parameters:
        `conversationId` - the conversationId
        `name` - A user-friendly name to label the conversation (max length 100 characters)
        `description` - A string describing the purpose of the conversation (max length 100 characters)
        `iconUrl` - An iconUrl to display in the conversation list
        `metadata` - The conversation metadata (JSON Object)
        `callback` - An optional `AvMessagingSdkCallback` instance to be notified of the result.
      See Also:
        `AvMessagingSdkCallback`, `AvMessagingSdkCallback.Response`

    - #### destroy

          public static void destroy()

      Terminate the AvMessagingSdk facilities.

      AvMessagingSdk is automatically terminated when the application exits. This method does not, usually, have to be called manually.

    - #### getSettings

          public static Settings getSettings()

      Accessor method for the SDK settings.

      Use this object to update settings at run time. Note: Some settings may only be configured at init time. See the `Settings` class reference for more information.

      Returns:
        Settings object passed in `init(Application, Settings, AvMessagingSdkCallback)`, or null if AvMessagingSdk hasn't been initialized yet.
      See Also:
        `Settings`

    - #### getConversation

          public static Conversation getConversation()

      Accessor method for the current conversation.
      Returns:
        Current conversation, or null if AvMessagingSdk.init() hasn't been called yet.
      See Also:
        `Conversation`

    - #### getConversationById

          public static void getConversationById​(java.lang.String conversationId,
                                                 AvMessagingSdkCallback<Conversation> callback)

      Get a `Conversation` by its ID. This is an asynchronous call and requires a `AvMessagingSdkCallback` to retrieve the result.
      Parameters:
        `conversationId` - the ID of the conversation to be retrieved
        `callback` - An instance of `AvMessagingSdkCallback` to be notified of the result.
      See Also:
        `Conversation`

    - #### getConversationsList

          public static void getConversationsList​(AvMessagingSdkCallback<java.util.List<Conversation>> callback)

      Get the list of the 10 most recently active `Conversation`s for the current user, sorted from most recently updated to last.

      Note that these conversations will only contain the most recent message for that conversation. Use `getConversationById(String, AvMessagingSdkCallback)` to retrieve the full details of a conversation, or `loadConversation(String, AvMessagingSdkCallback)` to make it active.

      Parameters:
        `callback` - An instance of `AvMessagingSdkCallback` to be notified of the result.
      See Also:
        `getConversationById(String, AvMessagingSdkCallback)`, `loadConversation(String, AvMessagingSdkCallback)`, `getConversation()`

    - #### getMoreConversationsList

          public static void getMoreConversationsList​(AvMessagingSdkCallback<java.util.List<Conversation>> callback)

      Get the list of the 10 more recently active `Conversation`s for the current user, sorted from most recently updated to last.

      Note that these conversations will only contain the most recent message for that conversation. Use `getConversationById(String, AvMessagingSdkCallback)` to retrieve the full details of a conversation, or `loadConversation(String, AvMessagingSdkCallback)` to make it active.

      Parameters:
        `callback` - An instance of `AvMessagingSdkCallback` to be notified of the result.
      See Also:
        `getConversationById(String, AvMessagingSdkCallback)`, `loadConversation(String, AvMessagingSdkCallback)`, `getConversation()`

    - #### hasMoreConversations

          public static boolean hasMoreConversations()

      Accessor method for knowing if there are more conversations to be fetched or not.
      Returns:
        true if there is more conversations to be fetched or false if not.

    - #### getConfig

          public static Config getConfig()

      Accessor method for the currently connected app configuration.
      Returns:
        Current app configuration, or null if AvMessagingSdk.init() hasn't been called yet.
      See Also:
        `Config`

    - #### getInitializationStatus

          public static InitializationStatus getInitializationStatus()

      Accessor method for the current Initialization status.
      Returns:
        Initialization status, or null if `init(Application, Settings, AvMessagingSdkCallback)` hasn't been called yet.
      See Also:
        `InitializationStatus`

    - #### getAvMessagingSdkConnectionStatus

          public static AvMessagingSdkConnectionStatus getAvMessagingSdkConnectionStatus()

      Accessor method for the current `AvMessagingSdkConnectionStatus`, or null if `init(Application, Settings, AvMessagingSdkCallback)` hasn't been called yet.
      See Also:
        `AvMessagingSdkConnectionStatus`

    - #### getLastLoginResult

          public static LoginResult getLastLoginResult()

      Accessor for last known `LoginResult` or `null` if the user is anonymous or `init(Application, Settings, AvMessagingSdkCallback)` hasn't been called
      See Also:
        `LoginResult`

    - #### getFirebaseCloudMessagingProjectId

          public static java.lang.String getFirebaseCloudMessagingProjectId()

      Accessor method to get the Firebase Cloud Messaging project id that was linked to the application via the Web portal.
      Returns:
        The Firebase Cloud Messaging project Id

    - #### setFirebaseCloudMessagingToken

          public static void setFirebaseCloudMessagingToken​(java.lang.String token)

      Method used to register the Firebase Cloud Messaging token to AvMessagingSdk
      Parameters:
        `token` - The Firebase Cloud Messaging token

    - #### setFirebaseCloudMessagingToken

          public static void setFirebaseCloudMessagingToken​(java.lang.String token,
                                                            AvMessagingSdkCallback<LoginResult> callback)

      Method used to register the Firebase Cloud Messaging token to AvMessagingSdk
      Parameters:
        `token` - The Firebase Cloud Messaging token
        `callback` - The callback to be called when token is received by AvMessagingSdk

    - #### setConversationDelegate

          public static void setConversationDelegate​(ConversationDelegate conversationDelegate)

      Sets the `ConversationDelegate`

      This delegate will be notified before the delegate set using `addConversationUiDelegate(int, ConversationDelegate)`

      Any delegate functions with the form boolean return type will prevent notification of conversationUiDelegate

      See `addConversationUiDelegate(int, ConversationDelegate)`

      Parameters:
        `conversationDelegate` - an instance of `ConversationDelegate`

    - #### setConversationInputDisplayed

          public static void setConversationInputDisplayed​(boolean displayed)

      Toggles whether the input bar is displayed on the conversation view.

    - #### getConversationDelegate

          public static ConversationDelegate getConversationDelegate()

      Gets the delegate set via `setConversationDelegate(ConversationDelegate)`.
      Returns:
        an instance of `ConversationDelegate`

    - #### addConversationUiDelegate

          public static void addConversationUiDelegate​(int key,
                                                       ConversationDelegate conversationUiDelegate)

      Add a `ConversationDelegate` used by the avMessagingSdk-ui package

      The primary use of this property is to notify the AvMessagingSdk UI of changes in the Conversation

      Note that this delegate will be notified after the delegate set using `setConversationDelegate(ConversationDelegate)`

      See `setConversationDelegate(ConversationDelegate)`

      Parameters:
        `key` - the key to use, must be >= 1
        `conversationUiDelegate` - an instance of `ConversationDelegate`

    - #### getConversationUiDelegate

          public static ConversationDelegate getConversationUiDelegate​(int key)

      Gets a delegate set via `addConversationUiDelegate(int key, ConversationDelegate)` using the key.
      Parameters:
        `key` - the key to use
      Returns:
        an instance of `ConversationDelegate`, null if not delegate for key

    - #### getConversationDelegates

          public static java.util.Collection<ConversationDelegate> getConversationDelegates()

      Gets the collection of `ConversationDelegate` that have been set on the SDK as a `SortedMap` where the integrator defined delegate will appear before the delegate used to notify the AvMessagingSdk UI
      Returns:
        a `SortedMap` of `ConversationDelegate`

    - #### setConversationViewDelegate

          public static void setConversationViewDelegate​(ConversationViewDelegate conversationViewDelegate)

      Sets the `ConversationViewDelegate`

      The delegate allows you to be notified of events related to the conversation view

      Parameters:
        `conversationViewDelegate` - an instance of `ConversationViewDelegate`

    - #### getConversationViewDelegate

          public static ConversationViewDelegate getConversationViewDelegate()

      Gets the delegate set via `setConversationViewDelegate(ConversationViewDelegate)`.
      Returns:
        an instance of `ConversationViewDelegate`

    - #### setMessageModifierDelegate

          public static void setMessageModifierDelegate​(MessageModifierDelegate messageModifierDelegate)

      Sets the `MessageModifierDelegate`

      The delegate allows you to change the way messages are displayed or sent to AvMessagingSdk.

      Parameters:
        `messageModifierDelegate` - The messageModifierDelegate

    - #### getMessageModifierDelegate

          public static MessageModifierDelegate getMessageModifierDelegate()

      Gets the delegate set via `setMessageModifierDelegate(MessageModifierDelegate)`.
      Returns:
        an instance of `MessageModifierDelegate`