Skip to main content

Initialize the SDK

Call NCEngine.initialize() before you connect to the server or use messaging features. Initialization sets up server endpoints, push notifications, logging, and storage options.

If this is your first time using Nexconn, start with Send your first message to register a developer account and set up your project.

Before you begin

Push notifications

The Nexconn SDK includes built-in push notification support along with third-party push service integration. Push initialization is triggered automatically after SDK initialization. Configure push settings before calling initialize(). For details, see Push notifications.

Process model

The Nexconn SDK supports both single-process and multi-process modes. Multi-process mode is enabled by default and starts the following processes after initialization:

  1. Main process — Your app's primary process.
  2. <package_name>:ipc — Core messaging process, isolated from the main process.
  3. io.rong.push — Push notification process. Whether this process starts depends on the push channel configuration. See Push notifications.

Basic initialization

Call initialize() in your app's onCreate() method with a production or development App Key.

kotlin
// Minimal initialization
NCEngine.initialize(InitParams(context, "your-app-key"))

// With optional configuration
NCEngine.initialize(InitParams(context, "your-app-key").apply {
logLevel = LogLevel.DEBUG
naviServer = "nav.custom-server.com"
areaCode = AreaCode.SG
enablePush = true
})

InitParams reference

ParameterTypeRequiredDefaultDescription
contextContextYesApplication context
appKeyStringYesApp Key (production or development)
logLevelLogLevelNoWARNLog output level
naviServerStringNonullCustom navigation server URL (private cloud)
areaCodeAreaCodeNoSGData center region code (required for overseas)
enablePushBooleanNotrueEnable push notifications
enableSyncEmptyTopConversationBooleanNofalseWhether to sync pinned channels that have no messages
compressOptionsCompressOptionsNonullImage and short video compression options; null uses SDK defaults

Data center configuration

The SDK uses AreaCode to resolve the correct navigation, file, statistics, and log server endpoints.

The default AreaCode is SG. Pass the value that matches your data center.

kotlin
NCEngine.initialize(InitParams(context, "Singapore_AppKey").apply {
areaCode = AreaCode.SG
})

Privacy compliance

Initialize the SDK only after the user accepts your privacy policy. Some app stores require this behavior in certain regions.

kotlin
class App : Application() {
override fun onCreate() {
super.onCreate()

val isPrivacyAccepted = getPrivacyStateFromSp()

if (isPrivacyAccepted) {
NCEngine.initialize(InitParams(applicationContext, "your-app-key"))
} else {
goToPrivacyActivity()
}
}
}

class PrivacyActivity : Activity() {
fun onAcceptPrivacy() {
savePrivacyStateToSp()
NCEngine.initialize(InitParams(applicationContext, "your-app-key"))
finish()
}
}

What's next