Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
flutter_push
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
顾海波
2025-01-22 13:30:01 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e2b3ddb2c57c90370da319a5a94a9a1b46d6eb7c
e2b3ddb2
1 parent
55246aba
【需求】数据对接
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
88 deletions
android/src/main/kotlin/com/ewin/flutter_push/EwinMixPushReceiver.kt
lib/entity/mix_push_message_entity.dart
lib/mix_push_plugin_listener.dart
android/src/main/kotlin/com/ewin/flutter_push/EwinMixPushReceiver.kt
View file @
e2b3ddb
...
...
@@ -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)
...
...
lib/entity/mix_push_message_entity.dart
View file @
e2b3ddb
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
,
};
}
...
...
lib/mix_push_plugin_listener.dart
View file @
e2b3ddb
...
...
@@ -27,10 +27,10 @@ class XiaoMiPushPluginListener {
:
null
;
// 封装回调类型和参数
Xiao
MixPushListenerTypeEnum
?
type
;
MixPushListenerTypeEnum
?
type
;
// 初始化类型
for
(
var
item
in
Xiao
MixPushListenerTypeEnum
.
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
Xiao
MixPushListenerTypeEnum
.
RequirePermissions
:
case
MixPushListenerTypeEnum
.
RequirePermissions
:
break
;
case
Xiao
MixPushListenerTypeEnum
.
NotificationMessageClicked
:
case
MixPushListenerTypeEnum
.
NotificationMessageClicked
:
params
=
MixPushMessageEntity
.
fromJson
(
params
);
break
;
case
Xiao
MixPushListenerTypeEnum
.
ReceivePassThroughMessage
:
case
MixPushListenerTypeEnum
.
ReceivePassThroughMessage
:
params
=
MixPushMessageEntity
.
fromJson
(
params
);
break
;
case
Xiao
MixPushListenerTypeEnum
.
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
Xiao
MixPushListenerTypeEnum
.
NotificationMessageArrived
:
case
MixPushListenerTypeEnum
.
NotificationMessageArrived
:
params
=
MixPushMessageEntity
.
fromJson
(
params
);
break
;
}
...
...
@@ -88,10 +88,10 @@ class XiaoMiPushPluginListener {
/// 监听器值模型
typedef
ListenerValue
<
P
>
=
void
Function
(
Xiao
MixPushListenerTypeEnum
type
,
P
?
params
);
MixPushListenerTypeEnum
type
,
P
?
params
);
/// 监听器类型枚举
enum
Xiao
MixPushListenerTypeEnum
{
enum
MixPushListenerTypeEnum
{
NotificationMessageClicked
,
RequirePermissions
,
ReceivePassThroughMessage
,
...
...
Please
register
or
login
to post a comment