fix:调整ios收到对讲后找到推送的消息并设置为已读

This commit is contained in:
liyi 2025-08-15 13:51:11 +08:00
parent 5ca0ba4a12
commit 88db0e850b
9 changed files with 126 additions and 23 deletions

View File

@ -62,10 +62,8 @@ FutureOr<void> main() async {
}
});
// //ToDo:
// runApp(MultiProvider(providers: [
// ChangeNotifierProvider(create: (_) => DebugInfoModel()),
// ], child: MyApp(isLogin: isLogin)));
// ios则初始化获取到voip token
// token callkit
if (Platform.isIOS) {
CallKitHandler.setupListener();
String? token = await CallKitHandler.getVoipToken();
@ -111,20 +109,4 @@ Future<void> privacySDKInitialization() async {
await jpushProvider.initJPushService();
NotificationService().init(); //
// /// ip如果属于国内才进行初始化
// final CheckIPEntity entity = await ApiRepository.to.checkIpAction(ip: '');
// if (entity.errorCode!.codeIsSuccessful) {
// String currentLanguage =
// CurrentLocaleTool.getCurrentLocaleString(); //
// // ip是国内的且选的是中文才初始化一键登录
// if (entity.data!.abbreviation?.toLowerCase() == 'cn' &&
// currentLanguage == 'zh_CN') {
// //
// final StarLockLoginLogic loginLogic = Get.put(StarLockLoginLogic());
// await JverifyOneClickLoginManage();
// loginLogic.state.isCheckVerifyEnable.value =
// await JverifyOneClickLoginManage().checkVerifyEnable();
// eventBus.fire(AgreePrivacyAgreement());
// }
// }
}

View File

@ -297,6 +297,11 @@ class LockListInfoItemEntity {
LockListInfoItemEntity copy() {
return LockListInfoItemEntity.fromJson(toJson());
}
@override
String toString() {
return 'LockListInfoItemEntity{keyId: $keyId, lockId: $lockId, lockName: $lockName, lockAlias: $lockAlias, electricQuantity: $electricQuantity, fwVersion: $fwVersion, hwVersion: $hwVersion, keyType: $keyType, passageMode: $passageMode, userType: $userType, startDate: $startDate, endDate: $endDate, weekDays: $weekDays, remoteEnable: $remoteEnable, faceAuthentication: $faceAuthentication, lastFaceValidateTime: $lastFaceValidateTime, nextFaceValidateTime: $nextFaceValidateTime, keyRight: $keyRight, keyStatus: $keyStatus, isLockOwner: $isLockOwner, sendDate: $sendDate, lockUserNo: $lockUserNo, senderUserId: $senderUserId, electricQuantityDate: $electricQuantityDate, electricQuantityStandby: $electricQuantityStandby, isOnlyManageSelf: $isOnlyManageSelf, restoreCount: $restoreCount, model: $model, vendor: $vendor, bluetooth: $bluetooth, lockFeature: $lockFeature, lockSetting: $lockSetting, hasGateway: $hasGateway, appUnlockOnline: $appUnlockOnline, mac: $mac, initUserNo: $initUserNo, updateDate: $updateDate, network: $network}';
}
}
class NetworkInfo {
@ -323,6 +328,11 @@ class NetworkInfo {
data['isOnline'] = isOnline;
return data;
}
@override
String toString() {
return 'NetworkInfo{peerId: $peerId, wifiName: $wifiName, isOnline: $isOnline}';
}
}
class Bluetooth {
@ -356,6 +366,11 @@ class Bluetooth {
data['signKey'] = signKey;
return data;
}
@override
String toString() {
return 'Bluetooth{bluetoothDeviceId: $bluetoothDeviceId, bluetoothDeviceName: $bluetoothDeviceName, publicKey: $publicKey, privateKey: $privateKey, signKey: $signKey}';
}
}
class LockFeature {
@ -442,6 +457,11 @@ class LockFeature {
data['isMJpeg'] = isMJpeg;
return data;
}
@override
String toString() {
return 'LockFeature{password: $password, passwordIssue: $passwordIssue, icCard: $icCard, fingerprint: $fingerprint, fingerVein: $fingerVein, palmVein: $palmVein, isSupportIris: $isSupportIris, d3Face: $d3Face, bluetoothRemoteControl: $bluetoothRemoteControl, videoIntercom: $videoIntercom, isSupportCatEye: $isSupportCatEye, isSupportBackupBattery: $isSupportBackupBattery, isNoSupportedBlueBroadcast: $isNoSupportedBlueBroadcast, wifiLockType: $wifiLockType, wifi: $wifi, isH264: $isH264, isH265: $isH265, isMJpeg: $isMJpeg}';
}
}
class LockSetting {
@ -486,6 +506,11 @@ class LockSetting {
}
return data;
}
@override
String toString() {
return 'LockSetting{attendance: $attendance, appUnlockOnline: $appUnlockOnline, remoteUnlock: $remoteUnlock, catEyeConfig: $catEyeConfig}';
}
}
// CatEyeConfig

View File

@ -8,7 +8,7 @@ import 'messageDetail_state.dart';
class MessageDetailLogic extends BaseGetXController {
final MessageDetailState state = MessageDetailState();
//
//
Future<void> readMessageDataRequest() async {
final MessageListEntity entity = await ApiRepository.to.readMessageLoadData(messageId:state.itemData.value.id!);
if (entity.errorCode!.codeIsSuccessful) {

View File

@ -24,14 +24,22 @@ class MessageListEntity {
}
return data;
}
@override
String toString() {
return 'MessageListEntity{errorCode: $errorCode, description: $description, errorMsg: $errorMsg, data: $data}';
}
}
class Data {
List<MessageItemEntity>? list;
int? pageNo;
int? pageSize;
int? total;
int? readCount;
int? unreadCount;
Data({this.list, this.pageNo, this.pageSize});
Data({this.list, this.pageNo, this.pageSize, this.total,this.readCount, this.unreadCount});
Data.fromJson(Map<String, dynamic> json) {
if (json['list'] != null) {
@ -42,6 +50,9 @@ class Data {
}
pageNo = json['pageNo'];
pageSize = json['pageSize'];
total = json['total'];
readCount = json['readCount'];
unreadCount = json['unreadCount'];
}
Map<String, dynamic> toJson() {
@ -51,8 +62,16 @@ class Data {
}
data['pageNo'] = pageNo;
data['pageSize'] = pageSize;
data['total'] = total;
data['readCount'] = readCount;
data['unreadCount'] = unreadCount;
return data;
}
@override
String toString() {
return 'Data{list: $list, pageNo: $pageNo, pageSize: $pageSize, total: $total, readCount: $readCount, unreadCount: $unreadCount}';
}
}
class MessageItemEntity {
@ -78,4 +97,9 @@ class MessageItemEntity {
data['readAt'] = readAt;
return data;
}
@override
String toString() {
return 'MessageItemEntity{id: $id, data: $data, createdAt: $createdAt, readAt: $readAt}';
}
}

View File

@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter_app_badger/flutter_app_badger.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:star_lock/app_settings/app_settings.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import '../../../network/api_repository.dart';
import '../../../tools/eventBusEventManage.dart';
@ -18,6 +19,10 @@ class MessageListLogic extends BaseGetXController {
final MessageListEntity entity = await ApiRepository.to
.messageListLoadData(pageNo: pageNo.toString(), pageSize: pageSize);
if (entity.errorCode!.codeIsSuccessful) {
AppLog.log('消息列表数据请求成功:${entity.data!.total}');
//
await FlutterAppBadger.updateBadgeCount(entity.data!.unreadCount!);
if (pageNo == 1) {
state.itemDataList.value = entity.data!.list!;
pageNo++;

View File

@ -2169,7 +2169,8 @@ class ApiProvider extends BaseProvider {
readMessageURL.toUrl,
jsonEncode({
'id': messageId,
}));
}),
isUnShowLoading: true);
//
Future<Response> deletMessageLoadData(String messageId) => post(

View File

@ -4,6 +4,7 @@ import 'dart:typed_data';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_pcm_sound/flutter_pcm_sound.dart';
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_settings.dart';
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
import 'package:star_lock/talk/starChart/constant/message_type_constant.dart';
import 'package:star_lock/talk/starChart/constant/talk_status.dart';
@ -15,6 +16,7 @@ import 'package:star_lock/talk/starChart/proto/generic.pb.dart';
import 'package:star_lock/talk/starChart/proto/talk_accept.pb.dart';
import 'package:star_lock/talk/starChart/proto/talk_expect.pb.dart';
import 'package:star_lock/tools/commonDataManage.dart';
import 'package:star_lock/tools/eventBusEventManage.dart';
import 'package:star_lock/tools/storage.dart';
import '../../star_chart_manage.dart';
@ -43,6 +45,25 @@ class UdpTalkAcceptHandler extends ScpMessageBaseHandle
//
talkeRequestOverTimeTimerManager.renew();
talkeRequestOverTimeTimerManager.cancel();
//
//
AppLog.log('msg:${scpMessage}');
AppLog.log('msg:${startChartManage.lockListPeerId}');
// id
final fromPeerId = scpMessage.FromPeerId;
if (fromPeerId != null && fromPeerId != '') {
startChartManage.lockListPeerId.forEach((element) {
if (element != null &&
element.network != null &&
element.network!.peerId == fromPeerId) {
//
eventBus.fire(ReadTalkMessageRefreshUI(element.lockName!));
}
});
}
// rbcuInfo数据
// startChartManage.startSendingRbcuInfoMessages(
// ToPeerId: startChartManage.lockPeerId);

View File

@ -1,11 +1,45 @@
import 'dart:async';
import 'package:flutter/widgets.dart';
import 'package:get/get.dart';
import 'package:star_lock/mine/message/messageList/messageList_entity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/network/start_chart_api.dart';
import 'package:star_lock/talk/starChart/constant/talk_status.dart';
import 'package:star_lock/talk/starChart/star_chart_manage.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/eventBusEventManage.dart';
import 'package:star_lock/tools/storage.dart';
class AppLifecycleObserver extends WidgetsBindingObserver {
//
StreamSubscription? _readMessageRefreshUIEvent;
void _readMessageRefreshUIAction() {
// eventBus
_readMessageRefreshUIEvent =
eventBus.on<ReadTalkMessageRefreshUI>().listen((event) async {
//
final MessageListEntity entity = await ApiRepository.to
.messageListLoadData(pageNo: '1', pageSize: '1');
if (entity.errorCode!.codeIsSuccessful) {
final lockName = event.lockName;
if (lockName != null && lockName.isNotEmpty) {
final readAt = entity.data?.list?.first.readAt == 0;
final data = entity.data?.list?.first.data;
if (readAt && data != null && data.contains(lockName)) {
//
final entity2 = await ApiRepository.to
.readMessageLoadData(messageId: entity.data!.list!.first.id!);
if (entity2.errorCode!.codeIsSuccessful) {
eventBus.fire(ReadMessageRefreshUI());
}
}
}
}
});
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
@ -37,6 +71,7 @@ class AppLifecycleObserver extends WidgetsBindingObserver {
Get.back();
}
StartChartManage().destruction();
_readMessageRefreshUIEvent?.cancel();
}
void onAppResumed() async {
@ -52,6 +87,9 @@ class AppLifecycleObserver extends WidgetsBindingObserver {
StartChartApi.to.startChartHost =
loginData!.starchart!.scdUrl ?? StartChartApi.to.startChartHost;
}
//
_readMessageRefreshUIAction();
print('App has resumed to the foreground.');
}

View File

@ -131,6 +131,13 @@ class ReadMessageRefreshUI {
ReadMessageRefreshUI();
}
///
class ReadTalkMessageRefreshUI {
ReadTalkMessageRefreshUI(this.lockName);
String lockName;
}
///
class ElectronicKeyListRefreshUI {
ElectronicKeyListRefreshUI();