提交 1883a424 authored 作者: 张国庆's avatar 张国庆

feat:适配其他链接

上级 19ae549e
...@@ -73,8 +73,13 @@ abstract class BaseMessageConfig ...@@ -73,8 +73,13 @@ abstract class BaseMessageConfig
debugPrint('未知消息类型'); debugPrint('未知消息类型');
debugPrint(data.toString()); debugPrint(data.toString());
} }
handleMessage(data);
} }
// 处理长连接消息
void handleMessage(dynamic data);
close() async { close() async {
clear(); clear();
clearNoticeDialog(); clearNoticeDialog();
...@@ -119,34 +124,15 @@ abstract class BaseMessageConfig ...@@ -119,34 +124,15 @@ abstract class BaseMessageConfig
noticeDialogWidgetController = NoticeDialogWidgetController(); noticeDialogWidgetController = NoticeDialogWidgetController();
} }
//刷新消息、获取未处理消息,重新连接websocket // 刷新消息、获取未处理消息,重新连接websocket
Future<void> refreshMessage(BuildContext context) async { Future<void> refreshMessage(BuildContext context) async {
// 校验消息相关配置字段 // 校验消息相关配置字段
if (StringUtil.isEmpty(messageConfig.userKey)) { final validationResult = validateMessageConfig();
ToastUtils.showCenter("userNo不能为空"); if (validationResult != null) {
return; ToastUtils.showCenter(validationResult);
}
if (StringUtil.isEmpty(messageConfig.companyNo)) {
ToastUtils.showCenter("companyNo不能为空");
return; return;
} }
if (StringUtil.isEmpty(messageConfig.accessToken)) {
ToastUtils.showCenter("登录token不能为空");
return;
}
if (StringUtil.isEmpty(messageConfig.inAppAccessKey)) {
ToastUtils.showCenter("inAppAccessKey不能为空");
return;
}
if (StringUtil.isEmpty(messageConfig.productCode)) {
ToastUtils.showCenter("productCode不能为空");
return;
}
if (StringUtil.isEmpty(messageConfig.webSocketUrl)) {
ToastUtils.showCenter("webSocketUrl不能为空");
return;
}
connectWebSocket(context); connectWebSocket(context);
List<MessageData> nList = await getUnReadMessage(); List<MessageData> nList = await getUnReadMessage();
...@@ -157,4 +143,27 @@ abstract class BaseMessageConfig ...@@ -157,4 +143,27 @@ abstract class BaseMessageConfig
// 处理公告 // 处理公告
setNotice(aList); setNotice(aList);
} }
// 校验消息配置字段
String? validateMessageConfig() {
if (StringUtil.isEmpty(messageConfig.userKey)) {
return "userNo不能为空";
}
if (StringUtil.isEmpty(messageConfig.companyNo)) {
return "companyNo不能为空";
}
if (StringUtil.isEmpty(messageConfig.accessToken)) {
return "登录token不能为空";
}
if (StringUtil.isEmpty(messageConfig.inAppAccessKey)) {
return "inAppAccessKey不能为空";
}
if (StringUtil.isEmpty(messageConfig.productCode)) {
return "productCode不能为空";
}
if (StringUtil.isEmpty(messageConfig.webSocketUrl)) {
return "webSocketUrl不能为空";
}
return null; // 所有校验通过
}
} }
...@@ -45,7 +45,11 @@ class MessageData { ...@@ -45,7 +45,11 @@ class MessageData {
messageNo = json['messageNo']; messageNo = json['messageNo'];
accessKey = json['accessKey']; accessKey = json['accessKey'];
companyNo = json['companyNo']; companyNo = json['companyNo'];
userNo = json['userNo']; if (json['userNo'] is String) {
userNo = json['userNo'];
} else {
userNo = json['userNo'].toString();
}
messageGroup = json['messageGroup']; messageGroup = json['messageGroup'];
messageSign = json['messageSign']; messageSign = json['messageSign'];
showType = json['showType']; showType = json['showType'];
......
name: clx_flutter_message name: clx_flutter_message
description: An in-app messaging plugin description: An in-app messaging plugin
version: 0.0.1 version: 0.0.2
homepage: homepage:
environment: environment:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论