基本使用用例

  • 初始化
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

  • V2TIMManager

    群组高级接口,包含了群组的高级功能,例如群成员邀请、非群成员申请进群等操作接口。

  • V2TIMFriendshipManager

    关系链接口,包含了好友的添加和删除,黑名单的添加和删除等逻辑。

  • V2TIMGroupManager

    群组高级接口,包含了群组的高级功能,例如群成员邀请、非群成员申请进群等操作接口。

Libraries

callbacks
conversation_type
friend_type
group_add_opt_type
group_application_handle_result
group_application_handle_status
group_application_type
group_change_info_type
group_member_filter_type
group_member_role
group_tips_elem_type
group_type
history_message_get_type
listener_type
log_level
message_elem_type
message_priority
message_status
offlinePushInfo
simpleMsgListenerType
v2_tim_callback
v2_tim_conversation
v2_tim_conversation_manager
v2_tim_conversation_result
v2_tim_custom_elem
v2_tim_face_elem
v2_tim_file_elem
v2_tim_friend_application
v2_tim_friend_application_result
v2_tim_friend_check_result
v2_tim_friend_group
v2_tim_friend_info
v2_tim_friend_info_result
v2_tim_friend_operation_result
v2_tim_friendship_manager
v2_tim_grant_administrator
v2_tim_group_application
v2_tim_group_application_result
v2_tim_group_at_info
v2_tim_group_attribute_changed
v2_tim_group_change_info
v2_tim_group_created
v2_tim_group_dismissed
v2_tim_group_info
v2_tim_group_info_changed
v2_tim_group_info_result
v2_tim_group_manager
v2_tim_group_member_change_info
v2_tim_group_member_full_info
v2_tim_group_member_info
v2_tim_group_member_info_result
v2_tim_group_member_operation_result
v2_tim_group_recycled
v2_tim_group_tips_elem
v2_tim_image
v2_tim_image_elem
v2_tim_location_elem
v2_tim_manager
v2_tim_member
v2_tim_member_enter
v2_tim_member_info_changed
v2_tim_member_invited
v2_tim_member_kicked
v2_tim_member_leave
v2_tim_merger_elem
v2_tim_message
v2_tim_message_manager
v2_tim_message_receipt
v2_tim_offline_push_info
v2_tim_offline_push_manager
v2_tim_quit_from_group
v2_tim_receive_rest_custom_data
v2_tim_recv_c2c_custom_message
v2_tim_recv_c2c_text_message
v2_tim_recv_group_custom_message
v2_tim_recv_group_text_message
v2_tim_revoke_administrator
v2_tim_signaling_manager
v2_tim_sound_elem
v2_tim_text_elem
v2_tim_user_full_info
v2_tim_user_info
v2_tim_value_callback
v2_tim_video_elem
V2TimAdvancedMsgListener
V2TimConversationListener
V2TimFriendshipListener
V2TimGroupListener
V2TimReceiveMessageOptInfo
V2TimSDKListener
V2TimSignalingListener
V2TimSimpleMsgListener

Models

v2_tim_application_processed Models
V2TimApplicationProcessed