Skip to main content

Quickstart

This guide helps you integrate Chat UI iOS into your app. You'll learn how to import the SDK, initialize it, connect users, display channel lists and message views, and test message delivery.

Requirements

  • iOS app targeting iOS 13.0 or later
  • Valid App Key for your target environment
  • User access token generated by your app server
  • User and group profile data (or managed info service) for displaying names and avatars

Before you start

  1. Register a developer account on Nexconn Console (registration creates a development app automatically)
  2. Copy the development App Key from Key Management
  3. Obtain an access token for your test user from your app server
  4. Prepare display data for users and groups
tip

Development and production environments use separate App Keys with isolated data. Switch to your production App Key before app release.

Import the SDK

Chat UI iOS supports CocoaPods and Swift Package Manager. This guide uses CocoaPods. See Import the SDK for all options.

swift
import NexconnChatSDK
import NexconnChatUI

Initialize the SDK

Initialize NCChatUI before using any SDK features. The NCInitParams configuration includes:

  • appKey: Your application identifier
  • areaCode: Data center location. The default is Singapore (NCAreaCodeSg / .sg).
  • naviServer: Custom navigation server address. Set it only for private navigation environments.
  • crashMonitorEnabled: Error reporting toggle
  • logLevel: Debug output level
caution

The SDK defaults to Singapore. Set areaCode explicitly when your App Key belongs to another data center. Configure naviServer only when your environment requires a private navigation server.

swift
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
let params = NCInitParams(appKey: "Your_AppKey")
params.areaCode = .sg // Set this to your App Key's data center.
// params.naviServer = "https://your-navi-server.example.com" // Private navigation only.

NCChatUI.shared().initialize(with: params)
return true
}

For advanced initialization options, see Initialize the SDK.

info

Find your App Key and data center in Nexconn Console under Service Management.

Get an access token

Access tokens authenticate individual users. Your app server must:

  1. Request tokens from Nexconn Server API
  2. Securely deliver them to client devices

For testing, use the API Debugger to generate tokens via the Register User endpoint.

danger

Never request tokens directly from client code. This would expose your App Secret through decompilation.

Connect to chat service

Establish a connection before using messaging features:

  1. Add connection status monitoring:

    swift
    final class ChatCoordinator: NSObject, NCChatUIConnectionStatusDelegate {
    override init() {
    super.init()
    NCChatUI.shared().addConnectionStatusDelegate(self)
    }

    func onNCChatUIConnectionStatusChanged(_ status: NCConnectionStatus) {
    // Handle connection state changes
    }
    }
  2. Connect with user credentials:

    swift
    func connectChatUI() {
    let params = NCConnectParams(token: "Your_Token")
    params.timeout = 30

    NCChatUI.shared().connect(
    with: params,
    databaseOpenedHandler: { isRecreated, error in
    // Local database ready
    },
    completionHandler: { userId, error in
    if let userId = userId {
    // Connection successful
    }
    }
    )
    }
  3. Configure user profile:

    swift
    let currentUser = NCChatUIUserInfo()
    currentUser.userId = "user_001"
    currentUser.name = "Ava"
    currentUser.avatarUrl = "https://example.com/avatar.png"

    NCChatUI.shared().currentUserInfo = currentUser
    NCChatUI.shared().userInfoDataSource = self
    NCChatUI.shared().groupInfoDataSource = self

Display channel list

Use the built-in NCChannelListViewController to show channels. This example filters for direct, group, and system channels:

swift
final class AppChannelListViewController: NCChannelListViewController {
}

func openChannelList() {
let displayChannelTypes = [
NSNumber(value: NCChannelType.direct.rawValue),
NSNumber(value: NCChannelType.group.rawValue),
NSNumber(value: NCChannelType.system.rawValue),
]

let channelListViewController =
AppChannelListViewController(displayConversationTypes: displayChannelTypes)
navigationController?.pushViewController(channelListViewController, animated: true)
}
note

The SDK provides the channel list view only. Implement search, tabs, and other UI elements in your app.

For profile display, either:

Channel list examples Channel list examples

Open channel view

The SDK includes NCChannelViewController for messaging. Handle channel selection in your list view subclass:

swift
override func onSelectedTableRow(
_ conversationModelType: NCChannelModelType,
conversationModel model: NCChannelModel,
at indexPath: IndexPath
) {
let channelViewController = NCChannelViewController(
channelType: model.channelType,
channelId: model.channelId
)
channelViewController.title = model.conversationTitle ?? "Channel"
navigationController?.pushViewController(channelViewController, animated: true)
}

Test messaging

For direct messaging testing:

  1. Use userId as the channelId
  2. Send a test message from your server
  3. Verify message receipt in the iOS app
  4. Send a reply from the app

Next steps

Explore these features: