initSDK method
Future<V2TimValueCallback<bool> >
initSDK({
- required int sdkAppID,
- required int loglevel,
- required V2TimSDKListener listener,
- required int uiPlatform,
- bool? showImLog,
- List<
V2TimPlugins> ? plugins,
override
初始化SDK
参数
@required int sdkAppID 应用 ID,必填项,可以在控制台中获取
@required int loglevel 配置信息
@required [InitListener] listener SDK的回调
返回
true:成功;
false:失败
Implementation
@override
Future<V2TimValueCallback<bool>> initSDK({
required int sdkAppID,
required int loglevel,
required V2TimSDKListener listener,
required int uiPlatform,
bool? showImLog,
List<V2TimPlugins>? plugins,
}) async {
final String uuid = Utils.generateUniqueString();
initSDKListenerList[uuid] = listener;
MethodChannelTencentCloudChatSdk.needLog = showImLog ?? true;
String windowsDownloadPath = "";
if (Platform.isWindows) {
final Directory tempDir = await getApplicationDocumentsDirectory();
String tp = tempDir.path;
var imDirec = Directory("$tp\\TencentCloudChat\\");
var imConfigDirec = Directory("$tp\\TencentCloudChat\\Config\\");
var imLogDirec = Directory("$tp\\TencentCloudChat/Log\\");
var imDownLoadDirec = Directory("$tp\\TencentCloudChat\\DownLoad\\");
if (!imDirec.existsSync()) {
imDirec.createSync(recursive: true);
}
if (!imConfigDirec.existsSync()) {
imConfigDirec.createSync(recursive: true);
}
if (!imLogDirec.existsSync()) {
imLogDirec.createSync(recursive: true);
}
if (!imDownLoadDirec.existsSync()) {
imDownLoadDirec.createSync(recursive: true);
}
windowsDownloadPath = imDirec.path;
}
Map<String, dynamic> param = {
"sdkAppID": sdkAppID,
"logLevel": loglevel,
"listenerUuid": uuid,
"uiPlatform": uiPlatform,
"showImLog": showImLog,
"plugins": plugins?.map((e) => e.index.toString()).toList() ?? [],
"tempPath": windowsDownloadPath,
};
var finalParam = buildTimManagerParam(param);
Map returnData = await _channel.invokeMethod(
'initSDK',
finalParam,
);
var formatData = formatJson(returnData);
var res = V2TimValueCallback<bool>.fromJson(formatData);
log("initSDK", param, res.toLogString());
return res;
}