Initialization
Before using any features of the CallKit SDK, you must complete the initialization configuration. This guide will walk you through the proper setup for CallKit initialization.
- The initialization method only needs to be called once during the entire application lifecycle.
- After initialization, the system will launch the main application process, IPC communication process, and push service process.
- We recommend performing initialization in the
onCreate()method of the Application class.
Prerequisites
Obtain App Key
Before initializing the SDK, you need to obtain the App Key for your application from the RC Console.
Steps to obtain:
- Log in to the RC Console and view the App Keys for your created applications.
- Select your application. If you have multiple applications, pay attention to the application name (labeled as 1 in the diagram below).
- Choose the corresponding App Key based on your environment requirements. RC provides two separate sets of App Key / Secret for each application to isolate production and development environments. When obtaining the App Key, ensure you select the correct environment (labeled as 2 in the diagram below).
Environment descriptions:
- Development environment: Used during development and testing phases.
- Production environment: Used for officially released applications (requires prior application approval).
- If you are not the application creator, confirm that the displayed data center matches your expectations.
- Without application approval, you can only use the App Key for the development environment.
- Keep your App Secret secure and avoid exposing it to third parties.
Pre-Initialization Configuration
Before initializing the SDK, complete the following configurations:
-
Enable RTC Service: The RTC service must be manually enabled in the Console. Depending on your application's business type, enable the corresponding RTC service.
-
Configure Global Data Center (if applicable): If your application uses a global data center, pay special attention to the following configurations:
-
The CallKit SDK is built on the IMKit SDK and uses the signaling channel capabilities provided by IMLib within IMKit.
-
You must modify the default service address of the IMKit SDK to the global data center address before initialization.
-
If not configured, the SDK will default to connecting to the China (Beijing) Data Center, which may cause service exceptions.
-
Initialize the SDK
The CallKit SDK relies on the IM SDK as its signaling channel, so you need to initialize the IMKit SDK first.
Initialization timing:
- We recommend calling it in the
onCreate()method of the Application class or when loading the RTC functionality module. Initialization is required only once during the application lifecycle.
Sample code:
The following example demonstrates how to initialize the SDK in the Application class:
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
// Replace with the actual App Key obtained from the Console
String appKey = "YourAppKey"; // Example: bos9p5rlcm2ba
// Create initialization configuration (using default settings)
InitOption initOption = new InitOption.Builder().build();
// Initialize the IM SDK
IMCenter.init(this, appKey, initOption);
}
}
- The core class of IMKit is IMCenter.
- Always replace "YourAppKey" in the example with the real App Key obtained from the Console.
Multi-Process Explanation
The RC SDK uses a multi-process mechanism by default (to modify the process mode, refer to the Process Explanation documentation). After initialization, the application will launch the following processes:
- The main application process.
<application package name>:ipc. This process is the core IM communication process and is isolated from the main process tasks.io.rong.push: The default push process for RC. Whether this process starts depends on the push channel activation strategy. For details, refer to Enable Push Notifications.