Skip to main content


Feature Introduction


Initialization is the first step for the client to call the SDK. Within the lifespan of the application, it can only be called once. Repeated calls might lead to unforeseen problems.


(1) After successful initialization, set various listeners, with examples provided in the respective Quick Integration sections for each platform; (2) The client's underlying logs will be stored in the specified directory, available for debugging.

Function Prototype

- (BOOL)initSDKWithConfig:(OIMInitConfig *)config
onConnecting:(nullable OIMVoidCallback)onConnecting
onConnectFailure:(nullable OIMFailureCallback)onConnectFailure
onConnectSuccess:(nullable OIMVoidCallback)onConnectSuccess
onKickedOffline:(nullable OIMVoidCallback)onKickedOffline
onUserTokenExpired:(nullable OIMVoidCallback)onUserTokenExpired;

Input Parameters

Parameter NameParameter TypeMandatoryDescription
configOIMInitConfigYesInitialization parameters

Return Result

NameData TypeDescription
successBOOLIndicator of initialization success
onConnectingOIMVoidCallbackConnecting callback
onConnectFailureOIMFailureCallbackConnection failure callback
onConnectSuccessOIMFailureCallbackConnection success callback
onKickedOfflineOIMVoidCallbackKicked offline callback
onUserTokenExpiredOIMVoidCallbackToken expiration callback

Code Example

OIMInitConfig *config = [OIMInitConfig new];
config.apiAddr = @"";
config.wsAddr = @"";
config.objectStorage = @"";

BOOL success = [OIMManager.manager initSDKWithConfig:config

} onConnectFailure:^(NSInteger code, NSString * _Nullable msg) {
// Connection failure callback function
// code error code
// error error message
} onConnectSuccess:^{
// SDK successfully connected to the IM server
} onKickedOffline:^{
// SDK is connecting to the IM server
} onUserTokenExpired:^{
// Online ticket has expired: At this point, you need to generate a new token and call the login() function again to log in.