tencent_im_sdk_plugin 3.5.4 copy "tencent_im_sdk_plugin: ^3.5.4" to clipboard
tencent_im_sdk_plugin: ^3.5.4 copied to clipboard

discontinuedreplaced by: tencent_cloud_chat_sdk
outdated

tencent_im_sdk_plugin由腾讯云即时通信IM精简版Native SDK封装而成,包含了精简版SDK的全部功能。

基本使用用例

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

29
likes
0
pub points
80%
popularity

Publisher

verified publishercomm.qq.com

tencent_im_sdk_plugin由腾讯云即时通信IM精简版Native SDK封装而成,包含了精简版SDK的全部功能。

Homepage

License

unknown (license)

Dependencies

flutter, flutter_web_plugins, js, json_annotation, mime_type, path

More

Packages that depend on tencent_im_sdk_plugin