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;
final Directory tempDir = await getTemporaryDirectory();
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);
}
return V2TimValueCallback<bool>.fromJson(
formatJson(
await _channel.invokeMethod(
'initSDK',
buildTimManagerParam(
{
"sdkAppID": sdkAppID,
"logLevel": loglevel,
"listenerUuid": uuid,
"uiPlatform": uiPlatform,
"showImLog": showImLog,
"plugins": plugins?.map((e) => e.index.toString()).toList() ?? [],
"tempPath": imDirec.path,
},
),
),
),
);
}