NCChatUI

public final class NCChatUI

NCChatUI — the main entry point for the ChatUI SDK.

Wraps nexconn-chat initialization and connection, provides a ChatUIFragmentFactory for all UI screens, and exposes an internal event bus for message and channel events.


// 1. Initialize in Application.onCreate
NCChatUI.initialize(new InitParams(context, "your-app-key"));

// 2. Connect after login
NCChatUI.connect(new ConnectParams("user-token"), (userId, error) -> {
    if (error == null) { // connected
    }
});

// 3. Replace any screen with a custom Fragment
NCChatUI.setFragmentFactory(new MyCustomFragmentFactory());

See also

ChatUIFragmentFactory
ai.nexconn.chat.NCEngine

Functions

Link copied to clipboard
public static void addCancelSendMediaMessageListener(Runnable listener)
Registers a cancel-send-media listener.
Link copied to clipboard
public static void addChannelEventListener(ChannelEventListener listener)
Registers a channel event listener.
Link copied to clipboard
public static void addMessageEventListener(MessageEventListener listener)
Registers a message event listener.
Link copied to clipboard
public static void cancelSendMediaMessage(Message message, ErrorHandler handler)
Cancels an in-progress media message upload.
Link copied to clipboard
public static void connect(ConnectParams params, ConnectHandler handler)
Connects to the server using a business token.
Link copied to clipboard
public static BaseChannel createChannel(ChannelIdentifier identifier)
Creates the appropriate BaseChannel subtype for the given ChannelIdentifier.
Link copied to clipboard
public static void deleteLocalMessages(ChannelIdentifier identifier, List<Message> messages, ErrorHandler handler)
Deletes messages from the local database only, then dispatches a DeleteEvent so that the message list refreshes immediately.
Link copied to clipboard
public static void deleteMessageForAll(ChannelIdentifier identifier, Message message, OperationHandler<Message> handler)
Recalls (deletes for all participants) a message and dispatches a DeleteEvent to all registered MessageEventListeners.
Link copied to clipboard
public static void deleteMessages(ChannelIdentifier identifier, List<Message> messages, ErrorHandler handler)
Deletes messages for the current user (local + server-side for self) and dispatches a to all registered MessageEventListeners.
Link copied to clipboard
public static void disconnect()
Disconnects from the server while keeping the push channel alive.
Link copied to clipboard
public static List<Runnable> getCancelSendMediaListeners()
Returns the list of registered cancel-send-media listeners.
Link copied to clipboard
public static Context getContext()
Returns the Application context saved during initialization.
Link copied to clipboard
public static ChatUIFragmentFactory getFragmentFactory()
Returns the current ChatUIFragmentFactory.
Link copied to clipboard
public static List<MessageEventListener> getMessageEventListeners()
Returns the list of registered message event listeners.
Link copied to clipboard
public static void initialize(InitParams params)
Initializes the SDK.
Link copied to clipboard
public static void insertMessages(ChannelIdentifier identifier, List<InsertMessageItem> items, OperationHandler<Boolean> handler)
Inserts messages and dispatches an InsertEvent to all registered s.
Link copied to clipboard
public static boolean isInitialized()
Returns whether the SDK has been initialized.
Link copied to clipboard
public static void logout()
Disconnects from the server and closes the push channel.
Link copied to clipboard
public static void refreshMessage(RefreshEvent event)
Dispatches a message refresh event to all registered MessageEventListeners.
Link copied to clipboard
public static void removeCancelSendMediaMessageListener(Runnable listener)
Unregisters a cancel-send-media listener.
Link copied to clipboard
public static void removeChannelEventListener(ChannelEventListener listener)
Unregisters a previously registered channel event listener.
Link copied to clipboard
public static void removeMessageEventListener(MessageEventListener listener)
Unregisters a previously registered message event listener.
Link copied to clipboard
public static void saveDraft(ChannelIdentifier channelIdentifier, String draft, OperationHandler<Boolean> handler)
Saves a draft for the given channel and notifies all registered ChannelEventListeners via onSaveDraft on success.
Link copied to clipboard
public static void sendMediaMessage(ChannelIdentifier identifier, SendMediaMessageParams params, SendMediaMessageHandler handler)
Sends a media message and dispatches send-lifecycle events to all registered s.
Link copied to clipboard
public static void sendMessage(ChannelIdentifier identifier, SendMessageParams params, SendMessageHandler handler)
Sends a text/binary message and dispatches send-lifecycle events to all registered s.
Link copied to clipboard
public static void setFragmentFactory(ChatUIFragmentFactory factory)
Replaces the current ChatUIFragmentFactory.
Link copied to clipboard
public static void syncConversationReadStatus(ChannelIdentifier channelIdentifier, long timestamp, ErrorHandler handler)
Syncs the read status of a channel to the server and notifies all registered s via onClearedUnreadStatus on success.