基本使用用例
- 初始化
import 'package:tencent_im_sdk_plugin/tencent_im_sdk_plugin.dart';
import 'package:tencent_im_sdk_plugin/models/v2_tim_value_callback.dart';
import 'package:tencent_im_sdk_plugin/enum/log_level.dart';
import 'package:tencent_im_sdk_plugin/manager/v2_tim_manager.dart';
import 'package:tencent_im_sdk_plugin/models/v2_tim_callback.dart';
function initLisener(data){
String type = data.type;
switch(type){
case: 'onConnecting':
case: 'onConnectSuccess':
case: 'onConnectFailed':
case: 'onKickedOffline':
case: 'onUserSigExpired':
case: 'onSelfInfoUpdated':
}
}
//获取腾讯即时通信IM manager;
V2TIMManager timManager = TencentImSDKPlugin.v2TIMManager;
//初始化SDK
V2TimValueCallback<bool> initRes = await timManager.initSDK(
sdkAppID: sdkAppID,//填入在控制台上申请的sdkappid
loglevel: LogLevel.V2TIM_LOG_DEBUG,
listener: initLisener,
);
//V2TimValueCallback 返回的所有数据结构
int code initRes.code;
String desc = initRes.desc;
bool data = initRes.data;//为V2TimValueCallback实例化时接收的泛型。
if(initRes.code == 0){
//初始化成功
//以下监听可按需设置,为防止遗漏消息,请在登录前设置监听。
//简单监听
timManager.addSimpleMsgListener(
listener: simpleMsgListener,
);
//群组监听
timManager.setGroupListener(
listener: groupListener,
);
//高级消息监听
timManager.getMessageManager().addAdvancedMsgListener(
listener: advancedMsgListener,
);
//关系链监听
timManager.getFriendshipManager().setFriendListener(
listener: friendListener,
);
//会话监听
timManager.getConversationManager().setConversationListener(
listener: conversationListener,
);
//设置信令相关监听
timManager.getSignalingManager().addSignalingListener(
listener: signalingListener,
);
V2TimCallback loginRes await timManager.login(
userID: userId,
userSig: userSig,
);
//V2TimCallback 返回的所有数据结构
int code = loginRes.code;
String desc = loginRes.desc;
if(code==0){
//登录成功
//发送消息
timManager.sendC2CTextMessage(text:text,userID:userID,)
//....
//这里可调用SDK的任何方法。
}else{
//登录失败
print(desc);
}
}else{
//初始化失败
}
Managers
-
群组高级接口,包含了群组的高级功能,例如群成员邀请、非群成员申请进群等操作接口。
-
关系链接口,包含了好友的添加和删除,黑名单的添加和删除等逻辑。
-
群组高级接口,包含了群组的高级功能,例如群成员邀请、非群成员申请进群等操作接口。
-
会话接口,包含了会话的获取,删除和更新的逻辑。
-
提供高级消息处理相关接口
-
提供离线推送相关的接口
-
提供了信令操作相关的接口
Libraries
- enum/conversation_type
- enum/friend_type
- enum/group_add_opt_type
- enum/group_application_handle_result
- enum/group_application_handle_status
- enum/group_application_type
- enum/group_change_info_type
- enum/group_member_filter_type
- enum/group_member_role
- enum/group_tips_elem_type
- enum/group_type
- enum/history_message_get_type
- enum/listener_type
- enum/log_level
- enum/message_elem_type
- enum/message_priority
- enum/message_status
- enum/simpleMsgListenerType
- manager/v2_tim_conversation_manager
- manager/v2_tim_friendship_manager
- manager/v2_tim_group_manager
- manager/v2_tim_manager
- manager/v2_tim_message_manager
- manager/v2_tim_offline_push_manager
- manager/v2_tim_signaling_manager
- models/v2_tim_application_processed
- models/v2_tim_callback
- models/v2_tim_conversation
- models/v2_tim_conversation_result
- models/v2_tim_custom_elem
- models/v2_tim_event_callback
- models/v2_tim_face_elem
- models/v2_tim_file_elem
- models/v2_tim_friend_application
- models/v2_tim_friend_application_result
- models/v2_tim_friend_check_result
- models/v2_tim_friend_group
- models/v2_tim_friend_info
- models/v2_tim_friend_info_result
- models/v2_tim_friend_operation_result
- models/v2_tim_grant_administrator
- models/v2_tim_group_application
- models/v2_tim_group_application_result
- models/v2_tim_group_at_info
- models/v2_tim_group_attribute_changed
- models/v2_tim_group_change_info
- models/v2_tim_group_created
- models/v2_tim_group_dismissed
- models/v2_tim_group_info
- models/v2_tim_group_info_changed
- models/v2_tim_group_info_result
- models/v2_tim_group_member_change_info
- models/v2_tim_group_member_full_info
- models/v2_tim_group_member_info
- models/v2_tim_group_member_info_result
- models/v2_tim_group_member_operation_result
- models/v2_tim_group_recycled
- models/v2_tim_group_tips_elem
- models/v2_tim_image
- models/v2_tim_image_elem
- models/v2_tim_location_elem
- models/v2_tim_member
- models/v2_tim_member_enter
- models/v2_tim_member_info_changed
- models/v2_tim_member_invited
- models/v2_tim_member_kicked
- models/v2_tim_member_leave
- models/v2_tim_message
- models/v2_tim_message_progress
- models/v2_tim_message_receipt
- models/v2_tim_offline_push_info
- models/v2_tim_quit_from_group
- models/v2_tim_receive_join_application
- models/v2_tim_receive_rest_custom_data
- models/v2_tim_recv_c2c_custom_message
- models/v2_tim_recv_c2c_text_message
- models/v2_tim_recv_group_custom_message
- models/v2_tim_recv_group_text_message
- models/v2_tim_revoke_administrator
- models/v2_tim_sdk_config
- models/v2_tim_signal_fullinfo
- models/v2_tim_sound_elem
- models/v2_tim_text_elem
- models/v2_tim_user_full_info
- models/v2_tim_user_info
- models/v2_tim_value_callback
- models/v2_tim_video_elem