Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
a90e5c83
Commit
a90e5c83
authored
Jan 11, 2022
by
hweeeeeei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
允许客户端自定义系统推送内容,消息model-push中添加"data"参数为自定义数据,可以为json或字符串
parent
125c76ce
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
common/src/main/java/com/wecloud/im/ws/model/request/PushModel.java
+6
-0
common/src/main/java/com/wecloud/im/ws/sender/PushTask.java
+9
-2
No files found.
common/src/main/java/com/wecloud/im/ws/model/request/PushModel.java
View file @
a90e5c83
...
@@ -22,4 +22,10 @@ public class PushModel implements Serializable {
...
@@ -22,4 +22,10 @@ public class PushModel implements Serializable {
*/
*/
private
String
subTitle
;
private
String
subTitle
;
/**
* 自定义系统推送内容
*/
private
String
data
;
}
}
common/src/main/java/com/wecloud/im/ws/sender/PushTask.java
View file @
a90e5c83
...
@@ -57,6 +57,7 @@ public class PushTask {
...
@@ -57,6 +57,7 @@ public class PushTask {
private
static
final
String
title
=
"title"
;
private
static
final
String
title
=
"title"
;
private
static
final
String
subTitle
=
"subTitle"
;
private
static
final
String
subTitle
=
"subTitle"
;
private
static
final
String
DATA
=
"data"
;
/**
/**
...
@@ -112,6 +113,7 @@ public class PushTask {
...
@@ -112,6 +113,7 @@ public class PushTask {
}
else
{
}
else
{
pushModel
.
setTitle
(
pushMap
.
get
(
title
));
pushModel
.
setTitle
(
pushMap
.
get
(
title
));
pushModel
.
setSubTitle
(
pushMap
.
get
(
subTitle
));
pushModel
.
setSubTitle
(
pushMap
.
get
(
subTitle
));
pushModel
.
setData
(
pushMap
.
get
(
DATA
));
}
}
this
.
push
(
pushModel
,
imClientReceiver
,
imApplication
);
this
.
push
(
pushModel
,
imClientReceiver
,
imApplication
);
...
@@ -212,7 +214,7 @@ public class PushTask {
...
@@ -212,7 +214,7 @@ public class PushTask {
conn
.
setRequestProperty
(
"Content-Type"
,
"application/json"
);
conn
.
setRequestProperty
(
"Content-Type"
,
"application/json"
);
conn
.
setRequestProperty
(
"Authorization"
,
"key="
+
imApplication
.
getFirebaseSecret
());
conn
.
setRequestProperty
(
"Authorization"
,
"key="
+
imApplication
.
getFirebaseSecret
());
JSONObject
json
=
new
JSONObject
();
JSONObject
json
=
new
JSONObject
();
//推送到哪台客户端机器
//推送到哪台客户端机器
设备token
json
.
put
(
"to"
,
imClientReceiver
.
getDeviceToken
());
json
.
put
(
"to"
,
imClientReceiver
.
getDeviceToken
());
JSONObject
info
=
new
JSONObject
();
JSONObject
info
=
new
JSONObject
();
info
.
put
(
"title"
,
pushModel
.
getTitle
());
info
.
put
(
"title"
,
pushModel
.
getTitle
());
...
@@ -220,6 +222,9 @@ public class PushTask {
...
@@ -220,6 +222,9 @@ public class PushTask {
//数据消息data 通知消息 notification
//数据消息data 通知消息 notification
json
.
put
(
"notification"
,
info
);
json
.
put
(
"notification"
,
info
);
// 自定义推送内容
json
.
put
(
"data"
,
pushModel
.
getData
());
OutputStreamWriter
wr
=
new
OutputStreamWriter
(
conn
.
getOutputStream
());
OutputStreamWriter
wr
=
new
OutputStreamWriter
(
conn
.
getOutputStream
());
jsonStr
=
json
.
toString
();
jsonStr
=
json
.
toString
();
wr
.
write
(
jsonStr
);
wr
.
write
(
jsonStr
);
...
@@ -242,7 +247,9 @@ public class PushTask {
...
@@ -242,7 +247,9 @@ public class PushTask {
private
void
apnsPush
(
PushModel
pushModel
,
ImClient
imClientReceiver
,
ImApplication
imApplication
)
{
private
void
apnsPush
(
PushModel
pushModel
,
ImClient
imClientReceiver
,
ImApplication
imApplication
)
{
// 查询apns证书
// 查询apns证书
ImIosApns
apns
=
imIosApnsService
.
getImIosApnsByAppId
(
imApplication
.
getId
());
ImIosApns
apns
=
imIosApnsService
.
getImIosApnsByAppId
(
imApplication
.
getId
());
Map
<
String
,
Object
>
customProperty
=
new
HashMap
<
String
,
Object
>(
1
);
Map
<
String
,
Object
>
customProperty
=
new
HashMap
<
String
,
Object
>(
3
);
// 自定义推送内容
customProperty
.
put
(
"data"
,
pushModel
.
getData
());
String
deviceToken
=
imClientReceiver
.
getDeviceToken
();
String
deviceToken
=
imClientReceiver
.
getDeviceToken
();
String
alertTitle
=
pushModel
.
getTitle
();
String
alertTitle
=
pushModel
.
getTitle
();
String
alertBody
=
pushModel
.
getSubTitle
();
String
alertBody
=
pushModel
.
getSubTitle
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment