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:
- Main process — Your app's primary process.
<package_name>:ipc— Core messaging process, isolated from the main process.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
- Java
// 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
})
// Minimal initialization
InitParams params = new InitParams(context, "your-app-key");
NCEngine.initialize(params);
// With optional configuration
InitParams params = new InitParams(context, "your-app-key");
params.setLogLevel(LogLevel.DEBUG);
params.setAreaCode(AreaCode.SG);
params.setEnablePush(true);
NCEngine.initialize(params);
InitParams reference
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
context | Context | Yes | — | Application context |
appKey | String | Yes | — | App Key (production or development) |
logLevel | LogLevel | No | WARN | Log output level |
naviServer | String | No | null | Custom navigation server URL (private cloud) |
areaCode | AreaCode | No | SG | Data center region code (required for overseas) |
enablePush | Boolean | No | true | Enable push notifications |
enableSyncEmptyTopConversation | Boolean | No | false | Whether to sync pinned channels that have no messages |
compressOptions | CompressOptions | No | null | Image 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
- Java
NCEngine.initialize(InitParams(context, "Singapore_AppKey").apply {
areaCode = AreaCode.SG
})
InitParams params = new InitParams(context, "Singapore_AppKey");
params.setAreaCode(AreaCode.SG);
NCEngine.initialize(params);
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
- Connect to the server — Establish a connection with an access token
- Push notifications — Configure push notification channels
- Send your first message — Complete quickstart tutorial