im_plugin_tencent_web 0.0.4
im_plugin_tencent_web: ^0.0.4 copied to clipboard
A Flutter plugin integrating Tencent IM for web, supporting chat and audio/video calls. Uses UI-free access method, providing ready-to-use APIs. Web-only integration.
im_plugin_tencent_web #
A Flutter plugin that inherits from Tencent IM
聊天互动使用:@tencentcloud/lite-chat (无UI)进行集成
音视频通话使用:Web&H5 (Vue2/Vue3) (含UI)进行集成
使用前准备 #
第一步 #
下载并复制以下文件到项目的 web 目录下
im_plugin.bundle.js
第二步 #
// 在 web/index.html 的 head之间添加
<script src="im_plugin.bundle.js" defer></script>
开始使用 #
初始化IM #
import 'package:im_plugin_tencent_web/im_plugin_tencent_web.dart';
import 'package:im_plugin_tencent_web/im/event_listener_config.dart';
ImPluginTencentWeb.initSdk(
sdkAppID: 0,
eventListener: EventListenerConfig(),
);
登录IM #
import 'package:im_plugin_tencent_web/im_plugin_tencent_web.dart';
try {
final imLoginRes = await ImPluginTencentWeb.login(
userID: '',
userSig: '',
);
print(imLoginRes);
} catch(err) {
print('登录出错:$err');
}
登出IM #
import 'package:im_plugin_tencent_web/im_plugin_tencent_web.dart';
try {
final imLogoutRes = await ImPluginTencentWeb.logout();
print(imLogoutRes);
} catch(err) {
print('登出出错:$err');
}
销毁IM #
import 'package:im_plugin_tencent_web/im_plugin_tencent_web.dart';
try {
await ImPluginTencentWeb.destroy();
} catch(err) {
print('销毁出错:$err');
}