init static method
Implementation
static Future<bool> init(String appKey, [NIMSDKOptions? options]) async {
XKitReporter().init(appKey: appKey, imVersion: NimCore.versionName);
setupLocator();
late NIMSDKOptions op;
if (options == null) {
if (Platform.isAndroid) {
final directory = await getExternalStorageDirectory();
op = NIMAndroidSDKOptions(
appKey: appKey,
shouldSyncStickTopSessionInfos: true,
enableTeamMessageReadReceipt: true,
enableFcs: false,
sdkRootDir: directory != null ? '${directory.path}/NIMFlutter' : null,
enablePreloadMessageAttachment: true,
);
} else if (Platform.isIOS) {
final directory = await getApplicationDocumentsDirectory();
op = NIMIOSSDKOptions(
appKey: appKey,
shouldSyncStickTopSessionInfos: true,
enableTeamMessageReadReceipt: true,
sdkRootDir: '${directory.path}/NIMFlutter',
apnsCername: 'ENTERPRISE',
pkCername: 'DEMO_PUSH_KIT',
enablePreloadMessageAttachment: true,
);
}
} else {
op = options;
}
var initResult = NimCore.instance.isInitialized;
if (!initResult) {
var nimInitResult = await NimCore.instance.initialize(op);
initResult = nimInitResult.isSuccess;
}
return initResult;
}