会话加好友
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:chat/models/user_info_model.dart';
|
||||
import 'package:chat/providers/auth_provider.dart';
|
||||
import 'package:chat/routes/auth_routes.dart';
|
||||
import 'package:chat/services/tim_service.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:tencent_im_sdk_plugin/tencent_im_sdk_plugin.dart';
|
||||
@@ -27,6 +28,7 @@ class AuthService extends GetxService {
|
||||
String get _userToken => _box.read('userToken') ?? '';
|
||||
Map<String, dynamic> get _userInfo => _box.read('userInfo') ?? {};
|
||||
|
||||
/// 用户信息,这个数据,在更新用户资料的时候,也应该更新
|
||||
Rx<UserInfoModel> userInfo = UserInfoModel.empty().obs;
|
||||
|
||||
@override
|
||||
@@ -43,6 +45,7 @@ class AuthService extends GetxService {
|
||||
}
|
||||
|
||||
Future<bool> login(String address) async {
|
||||
address = '12dUut3dG5xWi6JPDMjSSK6s2JPcfeKYL1';
|
||||
var result = await AuthProvider.login(address);
|
||||
|
||||
if (result != null) {
|
||||
@@ -58,6 +61,9 @@ class AuthService extends GetxService {
|
||||
|
||||
isLogin.value = true;
|
||||
|
||||
/// 登录IM
|
||||
TimService.to.initSdk();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -74,6 +80,8 @@ class AuthService extends GetxService {
|
||||
userId = '';
|
||||
userToken = '';
|
||||
|
||||
TimService.to.instance.logout();
|
||||
|
||||
userInfo.value = UserInfoModel.empty();
|
||||
isLogin.value = false;
|
||||
Get.offAllNamed(AuthRoutes.index);
|
||||
|
||||
@@ -28,6 +28,7 @@ import 'package:tencent_im_sdk_plugin/models/v2_tim_message.dart';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_message_receipt.dart';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_topic_info.dart';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_user_full_info.dart';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_user_status.dart';
|
||||
import 'package:tencent_im_sdk_plugin/tencent_im_sdk_plugin.dart';
|
||||
import 'package:vibration/vibration.dart';
|
||||
|
||||
@@ -42,7 +43,7 @@ class TimService extends GetxService {
|
||||
return TencentImSDKPlugin.v2TIMManager;
|
||||
}
|
||||
|
||||
int sdkAppID = 1400752974;
|
||||
int sdkAppID = 1400754674;
|
||||
|
||||
String get _userSig => AuthService.to.userSig;
|
||||
|
||||
@@ -79,15 +80,21 @@ class TimService extends GetxService {
|
||||
V2TimUserFullInfo info,
|
||||
) {},
|
||||
onUserSigExpired: () {},
|
||||
onUserStatusChanged: (List<V2TimUserStatus> userStatusList) {},
|
||||
onLog: (int logLevel, String logContent) {},
|
||||
),
|
||||
);
|
||||
|
||||
/// 登录
|
||||
await instance.login(
|
||||
var loginResult = await instance.login(
|
||||
userID: _userId,
|
||||
userSig: _userSig,
|
||||
);
|
||||
|
||||
if (loginResult.code != 0) {
|
||||
UiTools.toast(loginResult.desc);
|
||||
}
|
||||
|
||||
Get.put(TimConversationService());
|
||||
Get.put(TimFriendService());
|
||||
Get.put(TimGroupService());
|
||||
|
||||
Reference in New Issue
Block a user