fix:调整ios收到对讲后找到推送的消息并设置为已读
This commit is contained in:
parent
5ca0ba4a12
commit
88db0e850b
@ -62,10 +62,8 @@ FutureOr<void> main() async {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// //ToDo: 增加对讲调试、正式可删除
|
// 如果是ios则初始化获取到voip token
|
||||||
// runApp(MultiProvider(providers: [
|
// 上报时判断是否属于国内用户,国内用户不上报token 既不触发callkit
|
||||||
// ChangeNotifierProvider(create: (_) => DebugInfoModel()),
|
|
||||||
// ], child: MyApp(isLogin: isLogin)));
|
|
||||||
if (Platform.isIOS) {
|
if (Platform.isIOS) {
|
||||||
CallKitHandler.setupListener();
|
CallKitHandler.setupListener();
|
||||||
String? token = await CallKitHandler.getVoipToken();
|
String? token = await CallKitHandler.getVoipToken();
|
||||||
@ -111,20 +109,4 @@ Future<void> privacySDKInitialization() async {
|
|||||||
await jpushProvider.initJPushService();
|
await jpushProvider.initJPushService();
|
||||||
NotificationService().init(); // 初始化通知服务
|
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());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -297,6 +297,11 @@ class LockListInfoItemEntity {
|
|||||||
LockListInfoItemEntity copy() {
|
LockListInfoItemEntity copy() {
|
||||||
return LockListInfoItemEntity.fromJson(toJson());
|
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 {
|
class NetworkInfo {
|
||||||
@ -323,6 +328,11 @@ class NetworkInfo {
|
|||||||
data['isOnline'] = isOnline;
|
data['isOnline'] = isOnline;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'NetworkInfo{peerId: $peerId, wifiName: $wifiName, isOnline: $isOnline}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Bluetooth {
|
class Bluetooth {
|
||||||
@ -356,6 +366,11 @@ class Bluetooth {
|
|||||||
data['signKey'] = signKey;
|
data['signKey'] = signKey;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'Bluetooth{bluetoothDeviceId: $bluetoothDeviceId, bluetoothDeviceName: $bluetoothDeviceName, publicKey: $publicKey, privateKey: $privateKey, signKey: $signKey}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LockFeature {
|
class LockFeature {
|
||||||
@ -442,6 +457,11 @@ class LockFeature {
|
|||||||
data['isMJpeg'] = isMJpeg;
|
data['isMJpeg'] = isMJpeg;
|
||||||
return data;
|
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 {
|
class LockSetting {
|
||||||
@ -486,6 +506,11 @@ class LockSetting {
|
|||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'LockSetting{attendance: $attendance, appUnlockOnline: $appUnlockOnline, remoteUnlock: $remoteUnlock, catEyeConfig: $catEyeConfig}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 定义 CatEyeConfig 类
|
// 定义 CatEyeConfig 类
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import 'messageDetail_state.dart';
|
|||||||
class MessageDetailLogic extends BaseGetXController {
|
class MessageDetailLogic extends BaseGetXController {
|
||||||
final MessageDetailState state = MessageDetailState();
|
final MessageDetailState state = MessageDetailState();
|
||||||
|
|
||||||
//请求密码钥匙列表
|
// 将消息设置为已读
|
||||||
Future<void> readMessageDataRequest() async {
|
Future<void> readMessageDataRequest() async {
|
||||||
final MessageListEntity entity = await ApiRepository.to.readMessageLoadData(messageId:state.itemData.value.id!);
|
final MessageListEntity entity = await ApiRepository.to.readMessageLoadData(messageId:state.itemData.value.id!);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
|||||||
@ -24,14 +24,22 @@ class MessageListEntity {
|
|||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'MessageListEntity{errorCode: $errorCode, description: $description, errorMsg: $errorMsg, data: $data}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Data {
|
class Data {
|
||||||
List<MessageItemEntity>? list;
|
List<MessageItemEntity>? list;
|
||||||
int? pageNo;
|
int? pageNo;
|
||||||
int? pageSize;
|
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) {
|
Data.fromJson(Map<String, dynamic> json) {
|
||||||
if (json['list'] != null) {
|
if (json['list'] != null) {
|
||||||
@ -42,6 +50,9 @@ class Data {
|
|||||||
}
|
}
|
||||||
pageNo = json['pageNo'];
|
pageNo = json['pageNo'];
|
||||||
pageSize = json['pageSize'];
|
pageSize = json['pageSize'];
|
||||||
|
total = json['total'];
|
||||||
|
readCount = json['readCount'];
|
||||||
|
unreadCount = json['unreadCount'];
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
@ -51,8 +62,16 @@ class Data {
|
|||||||
}
|
}
|
||||||
data['pageNo'] = pageNo;
|
data['pageNo'] = pageNo;
|
||||||
data['pageSize'] = pageSize;
|
data['pageSize'] = pageSize;
|
||||||
|
data['total'] = total;
|
||||||
|
data['readCount'] = readCount;
|
||||||
|
data['unreadCount'] = unreadCount;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'Data{list: $list, pageNo: $pageNo, pageSize: $pageSize, total: $total, readCount: $readCount, unreadCount: $unreadCount}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MessageItemEntity {
|
class MessageItemEntity {
|
||||||
@ -78,4 +97,9 @@ class MessageItemEntity {
|
|||||||
data['readAt'] = readAt;
|
data['readAt'] = readAt;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'MessageItemEntity{id: $id, data: $data, createdAt: $createdAt, readAt: $readAt}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:flutter_app_badger/flutter_app_badger.dart';
|
import 'package:flutter_app_badger/flutter_app_badger.dart';
|
||||||
import 'package:flutter_local_notifications/flutter_local_notifications.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 'package:star_lock/tools/baseGetXController.dart';
|
||||||
import '../../../network/api_repository.dart';
|
import '../../../network/api_repository.dart';
|
||||||
import '../../../tools/eventBusEventManage.dart';
|
import '../../../tools/eventBusEventManage.dart';
|
||||||
@ -18,6 +19,10 @@ class MessageListLogic extends BaseGetXController {
|
|||||||
final MessageListEntity entity = await ApiRepository.to
|
final MessageListEntity entity = await ApiRepository.to
|
||||||
.messageListLoadData(pageNo: pageNo.toString(), pageSize: pageSize);
|
.messageListLoadData(pageNo: pageNo.toString(), pageSize: pageSize);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
|
AppLog.log('消息列表数据请求成功:${entity.data!.total}');
|
||||||
|
// 设置角标(直接设置一个数值)
|
||||||
|
await FlutterAppBadger.updateBadgeCount(entity.data!.unreadCount!);
|
||||||
|
|
||||||
if (pageNo == 1) {
|
if (pageNo == 1) {
|
||||||
state.itemDataList.value = entity.data!.list!;
|
state.itemDataList.value = entity.data!.list!;
|
||||||
pageNo++;
|
pageNo++;
|
||||||
|
|||||||
@ -2169,7 +2169,8 @@ class ApiProvider extends BaseProvider {
|
|||||||
readMessageURL.toUrl,
|
readMessageURL.toUrl,
|
||||||
jsonEncode({
|
jsonEncode({
|
||||||
'id': messageId,
|
'id': messageId,
|
||||||
}));
|
}),
|
||||||
|
isUnShowLoading: true);
|
||||||
|
|
||||||
// 删除消息
|
// 删除消息
|
||||||
Future<Response> deletMessageLoadData(String messageId) => post(
|
Future<Response> deletMessageLoadData(String messageId) => post(
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import 'dart:typed_data';
|
|||||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||||
import 'package:flutter_pcm_sound/flutter_pcm_sound.dart';
|
import 'package:flutter_pcm_sound/flutter_pcm_sound.dart';
|
||||||
import 'package:get/get.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/main/lockMian/entity/lockListInfo_entity.dart';
|
||||||
import 'package:star_lock/talk/starChart/constant/message_type_constant.dart';
|
import 'package:star_lock/talk/starChart/constant/message_type_constant.dart';
|
||||||
import 'package:star_lock/talk/starChart/constant/talk_status.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_accept.pb.dart';
|
||||||
import 'package:star_lock/talk/starChart/proto/talk_expect.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/commonDataManage.dart';
|
||||||
|
import 'package:star_lock/tools/eventBusEventManage.dart';
|
||||||
import 'package:star_lock/tools/storage.dart';
|
import 'package:star_lock/tools/storage.dart';
|
||||||
|
|
||||||
import '../../star_chart_manage.dart';
|
import '../../star_chart_manage.dart';
|
||||||
@ -43,6 +45,25 @@ class UdpTalkAcceptHandler extends ScpMessageBaseHandle
|
|||||||
// 同意接听之后,停止对讲请求超时监听定时器
|
// 同意接听之后,停止对讲请求超时监听定时器
|
||||||
talkeRequestOverTimeTimerManager.renew();
|
talkeRequestOverTimeTimerManager.renew();
|
||||||
talkeRequestOverTimeTimerManager.cancel();
|
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数据
|
// 启动发送rbcuInfo数据
|
||||||
// startChartManage.startSendingRbcuInfoMessages(
|
// startChartManage.startSendingRbcuInfoMessages(
|
||||||
// ToPeerId: startChartManage.lockPeerId);
|
// ToPeerId: startChartManage.lockPeerId);
|
||||||
|
|||||||
@ -1,11 +1,45 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:get/get.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/network/start_chart_api.dart';
|
||||||
import 'package:star_lock/talk/starChart/constant/talk_status.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/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';
|
import 'package:star_lock/tools/storage.dart';
|
||||||
|
|
||||||
class AppLifecycleObserver extends WidgetsBindingObserver {
|
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
|
@override
|
||||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||||
super.didChangeAppLifecycleState(state);
|
super.didChangeAppLifecycleState(state);
|
||||||
@ -37,6 +71,7 @@ class AppLifecycleObserver extends WidgetsBindingObserver {
|
|||||||
Get.back();
|
Get.back();
|
||||||
}
|
}
|
||||||
StartChartManage().destruction();
|
StartChartManage().destruction();
|
||||||
|
_readMessageRefreshUIEvent?.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void onAppResumed() async {
|
void onAppResumed() async {
|
||||||
@ -52,6 +87,9 @@ class AppLifecycleObserver extends WidgetsBindingObserver {
|
|||||||
StartChartApi.to.startChartHost =
|
StartChartApi.to.startChartHost =
|
||||||
loginData!.starchart!.scdUrl ?? StartChartApi.to.startChartHost;
|
loginData!.starchart!.scdUrl ?? StartChartApi.to.startChartHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 监听对讲消息处理角标已读
|
||||||
|
_readMessageRefreshUIAction();
|
||||||
print('App has resumed to the foreground.');
|
print('App has resumed to the foreground.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -131,6 +131,13 @@ class ReadMessageRefreshUI {
|
|||||||
ReadMessageRefreshUI();
|
ReadMessageRefreshUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 刷新接收到对讲消息后将消息设置为已读
|
||||||
|
class ReadTalkMessageRefreshUI {
|
||||||
|
ReadTalkMessageRefreshUI(this.lockName);
|
||||||
|
|
||||||
|
String lockName;
|
||||||
|
}
|
||||||
|
|
||||||
/// 刷新电子钥匙列表
|
/// 刷新电子钥匙列表
|
||||||
class ElectronicKeyListRefreshUI {
|
class ElectronicKeyListRefreshUI {
|
||||||
ElectronicKeyListRefreshUI();
|
ElectronicKeyListRefreshUI();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user