顾海波

【需求】数据对接

... ... @@ -21,6 +21,16 @@ class EwinMixPushReceiver : MixPushReceiver() {
this.invokeListener(MixListenerTypeEnum.ReceiveRegisterResult, platform)
}
override fun onNotificationMessageArrived(context: Context?, message: MixPushMessage?) {
message?.run {
if (isPassThrough){
this.invokeListener(MixListenerTypeEnum.ReceivePassThroughMessage, message)
}else{
this.invokeListener(MixListenerTypeEnum.NotificationMessageArrived, message)
}
}
}
override fun onNotificationMessageClicked(context: Context, message: MixPushMessage) {
this.invokeListener(MixListenerTypeEnum.NotificationMessageClicked, message)
... ...
class MixPushMessageEntity {
final bool? arrivedMessage;
final String? content;
final String? description;
final MixPushMessageExtra? extra;
final String? messageId;
final int? messageType;
final bool? notified;
final int? notifyId;
final int? notifyType;
final int? passThrough;
//通知栏标题,透传该字段为空
final String? title;
//通知栏副标题,透传该字段为空
final String? description;
//推送所属平台,比如mi/huawei
final String? platform;
//推送附属的内容信息
final String? payload;
//是否是透传推送
final bool? passThrough;
final String? msgId;
MixPushMessageEntity({
this.arrivedMessage,
this.content,
this.description,
this.extra,
this.messageId,
this.messageType,
this.notified,
this.notifyId,
this.notifyType,
this.passThrough,
this.title,
});
MixPushMessageEntity(
{this.title,
this.description,
this.platform,
this.payload,
this.passThrough,
this.msgId});
factory MixPushMessageEntity.fromJson(Map<String, dynamic> json) {
return MixPushMessageEntity(
arrivedMessage: json['arrivedMessage'],
content: json['content'],
description: json['description'],
extra: json['extra'] == null
? null
: MixPushMessageExtra.fromJson(json['extra']),
messageId: json['messageId'],
messageType: json['messageType'],
notified: json['notified'],
notifyId: json['notifyId'],
notifyType: json['notifyType'],
passThrough: json['passThrough'],
title: json['title'],
);
title: json['title'],
description: json['description'],
platform: json['platform'],
payload: json['payload'],
passThrough: json['passThrough'],
msgId: json['msgId']);
}
Map<String, dynamic> toJson() => {
'arrivedMessage': arrivedMessage,
'content': content,
'title': title,
'description': description,
'extra': extra == null ? null : extra!.toJson(),
'messageId': messageId,
'messageType': messageType,
'notified': notified,
'notifyId': notifyId,
'notifyType': notifyType,
'platform': platform,
'payload': payload,
'passThrough': passThrough,
'title': title,
'msgId': msgId,
};
}
class MixPushMessageExtra {
final String? highPriorityEvent;
final String? feTs;
final String? planId;
final String? source;
final String? notifyForeground;
final String? mTs;
class MixPushPlatformEntity {
final String? platformName;
final String? regId;
MixPushMessageExtra({
this.highPriorityEvent,
this.feTs,
this.planId,
this.source,
this.notifyForeground,
this.mTs,
});
MixPushPlatformEntity({this.platformName, this.regId});
factory MixPushMessageExtra.fromJson(Map<String, dynamic> json) {
return MixPushMessageExtra(
highPriorityEvent: json['high_priority_event'],
feTs: json['fe_ts'],
planId: json['__planId__'],
source: json['source'],
notifyForeground: json['notify_foreground'],
mTs: json['__m_ts'],
);
factory MixPushPlatformEntity.fromJson(Map<String, dynamic> json) {
return MixPushPlatformEntity(
platformName: json['platformName'], regId: json['regId']);
}
Map<String, dynamic> toJson() => {
'high_priority_event': highPriorityEvent,
'fe_ts': feTs,
'__planId__': planId,
'source': source,
'notify_foreground': notifyForeground,
'__m_ts': mTs,
'arrivedMessage': platformName,
'content': regId,
};
}
... ...
... ... @@ -27,10 +27,10 @@ class XiaoMiPushPluginListener {
: null;
// 封装回调类型和参数
XiaoMixPushListenerTypeEnum? type;
MixPushListenerTypeEnum? type;
// 初始化类型
for (var item in XiaoMixPushListenerTypeEnum.values) {
for (var item in MixPushListenerTypeEnum.values) {
var es = item.toString().split(".");
if (es[es.length - 1] == typeStr) {
type = item;
... ... @@ -45,21 +45,21 @@ class XiaoMiPushPluginListener {
// 回调触发
switch (type) {
case XiaoMixPushListenerTypeEnum.RequirePermissions:
case MixPushListenerTypeEnum.RequirePermissions:
break;
case XiaoMixPushListenerTypeEnum.NotificationMessageClicked:
case MixPushListenerTypeEnum.NotificationMessageClicked:
params = MixPushMessageEntity.fromJson(params);
break;
case XiaoMixPushListenerTypeEnum.ReceivePassThroughMessage:
case MixPushListenerTypeEnum.ReceivePassThroughMessage:
params = MixPushMessageEntity.fromJson(params);
break;
case XiaoMixPushListenerTypeEnum.CommandResult:
case MixPushListenerTypeEnum.CommandResult:
params = MixPushCommandMessageEntity.fromJson(params);
break;
case XiaoMixPushListenerTypeEnum.ReceiveRegisterResult:
params = MixPushCommandMessageEntity.fromJson(params);
case MixPushListenerTypeEnum.ReceiveRegisterResult:
params = MixPushPlatformEntity.fromJson(params);
break;
case XiaoMixPushListenerTypeEnum.NotificationMessageArrived:
case MixPushListenerTypeEnum.NotificationMessageArrived:
params = MixPushMessageEntity.fromJson(params);
break;
}
... ... @@ -88,10 +88,10 @@ class XiaoMiPushPluginListener {
/// 监听器值模型
typedef ListenerValue<P> = void Function(
XiaoMixPushListenerTypeEnum type, P? params);
MixPushListenerTypeEnum type, P? params);
/// 监听器类型枚举
enum XiaoMixPushListenerTypeEnum {
enum MixPushListenerTypeEnum {
NotificationMessageClicked,
RequirePermissions,
ReceivePassThroughMessage,
... ...