Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
push-platform-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d8eaf6e7
authored
Apr 15, 2021
by
fz
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.车家智能平台,android于iOS的开发模式参数分离设置
2.接口添加消息内容参数,作为通知扩展参数
1 parent
d055ffbe
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
15 deletions
src/main/java/com/glsx/modules/notify/factory/strategy/AliYunStrategy.java
src/main/java/com/glsx/modules/notify/model/BaseRequest.java
src/main/java/com/glsx/modules/notify/model/param/NotifyReqParam.java
src/main/java/com/glsx/modules/notify/push/BroadCastService.java
src/main/java/com/glsx/modules/notify/service/CarHomePushService.java
src/test/java/com/glsx/modules/notify/controller/DeviceControllerTest.java
src/main/java/com/glsx/modules/notify/factory/strategy/AliYunStrategy.java
View file @
d8eaf6e
...
@@ -11,6 +11,8 @@ import com.glsx.modules.notify.model.BaseRequest;
...
@@ -11,6 +11,8 @@ import com.glsx.modules.notify.model.BaseRequest;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.core.web.R
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -77,12 +79,13 @@ public class AliYunStrategy implements PushStrategy {
...
@@ -77,12 +79,13 @@ public class AliYunStrategy implements PushStrategy {
buildBaseRequest
(
pushRequest
,
request
);
buildBaseRequest
(
pushRequest
,
request
);
//IOS默认设置
//IOS默认设置
//ios通知跳转
//通知的扩展属性
Map
map
=
new
HashMap
();
Map
extParametersMap
=
request
.
getExtParametersMap
();
map
.
put
(
"type"
,
request
.
getType
());
if
(
MapUtils
.
isNotEmpty
(
extParametersMap
)){
String
extParameters
=
JSON
.
toJSONString
(
map
);
String
extParameters
=
JSON
.
toJSONString
(
extParametersMap
);
pushRequest
.
setIOSExtParameters
(
extParameters
);
}
pushRequest
.
setIOSExtParameters
(
extParameters
);
//设置开发环境
//设置开发环境
pushRequest
.
setIOSApnsEnv
(
request
.
getTestMode
());
pushRequest
.
setIOSApnsEnv
(
request
.
getTestMode
());
return
sendRequest
(
pushRequest
);
return
sendRequest
(
pushRequest
);
...
...
src/main/java/com/glsx/modules/notify/model/BaseRequest.java
View file @
d8eaf6e
...
@@ -2,6 +2,8 @@ package com.glsx.modules.notify.model;
...
@@ -2,6 +2,8 @@ package com.glsx.modules.notify.model;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.Map
;
@Data
@Data
public
class
BaseRequest
{
public
class
BaseRequest
{
...
@@ -84,7 +86,12 @@ public class BaseRequest {
...
@@ -84,7 +86,12 @@ public class BaseRequest {
private
String
activity
;
private
String
activity
;
/**
/**
* 点击通知后跳转,ios相关为type值
* 通知携带额外参数值,此处为消息内容
*/
private
String
msgBody
;
/**
* 通知的扩展属性
*/
*/
private
String
type
;
private
Map
<
String
,
String
>
extParametersMap
;
}
}
src/main/java/com/glsx/modules/notify/model/param/NotifyReqParam.java
View file @
d8eaf6e
...
@@ -18,4 +18,7 @@ public class NotifyReqParam {
...
@@ -18,4 +18,7 @@ public class NotifyReqParam {
@ApiModelProperty
(
value
=
"Android/iOS推送时的消息/通知内容,推送的内容大小是有限制的"
,
required
=
true
)
@ApiModelProperty
(
value
=
"Android/iOS推送时的消息/通知内容,推送的内容大小是有限制的"
,
required
=
true
)
private
String
body
;
private
String
body
;
@ApiModelProperty
(
value
=
"消息内容"
,
required
=
true
)
private
String
msgBody
;
}
}
src/main/java/com/glsx/modules/notify/push/BroadCastService.java
View file @
d8eaf6e
package
com
.
glsx
.
modules
.
notify
.
push
;
package
com
.
glsx
.
modules
.
notify
.
push
;
import
com.alibaba.fastjson.JSON
;
import
com.glsx.modules.notify.model.BaseRequest
;
import
com.glsx.modules.notify.model.BaseRequest
;
import
com.glsx.modules.notify.push.android.AndroidCustomizedcast
;
import
com.glsx.modules.notify.push.android.AndroidCustomizedcast
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.core.web.R
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.Map
;
@Service
@Service
@Slf4j
public
class
BroadCastService
{
public
class
BroadCastService
{
@Autowired
@Autowired
private
PushClient
client
;
private
PushClient
client
;
...
@@ -27,6 +33,19 @@ public class BroadCastService {
...
@@ -27,6 +33,19 @@ public class BroadCastService {
//通知文字描述
//通知文字描述
customizedcast
.
setText
(
baseRequest
.
getBody
());
customizedcast
.
setText
(
baseRequest
.
getBody
());
//通知的扩展属性
Map
<
String
,
String
>
extParametersMap
=
baseRequest
.
getExtParametersMap
();
if
(
MapUtils
.
isNotEmpty
(
extParametersMap
)){
extParametersMap
.
entrySet
().
stream
().
forEach
(
entry
->{
try
{
customizedcast
.
setExtraField
(
entry
.
getKey
(),
entry
.
getValue
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"友盟设置扩展参数异常===alias:{},extraParams:{},exception:"
,
baseRequest
.
getAlias
(),
JSON
.
toJSONString
(
extParametersMap
),
e
.
getMessage
());
}
});
}
//通知跳转,如果activity为空,默认跳转应用,否则跳转指定activity
//通知跳转,如果activity为空,默认跳转应用,否则跳转指定activity
String
activity
=
baseRequest
.
getActivity
();
String
activity
=
baseRequest
.
getActivity
();
if
(
StringUtils
.
isEmpty
(
activity
))
if
(
StringUtils
.
isEmpty
(
activity
))
...
...
src/main/java/com/glsx/modules/notify/service/CarHomePushService.java
View file @
d8eaf6e
...
@@ -8,6 +8,9 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -8,6 +8,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.Map
;
@Service
@Service
@Slf4j
@Slf4j
public
class
CarHomePushService
extends
PushService
{
public
class
CarHomePushService
extends
PushService
{
...
@@ -16,8 +19,12 @@ public class CarHomePushService extends PushService{
...
@@ -16,8 +19,12 @@ public class CarHomePushService extends PushService{
/**
/**
* DEV表示开发环境,PRODUCT表示生产环境
* DEV表示开发环境,PRODUCT表示生产环境
*/
*/
@Value
(
"${youmeng.carhome.testMode}"
)
@Value
(
"${youmeng.carhome.android.testMode}"
)
private
String
testMode
;
private
String
testMode_youmeng_android
;
@Value
(
"${aliyun.carhome.ios.testMode}"
)
private
String
testMode_aliyun_ios
;
/************************ android配置 ************************/
/************************ android配置 ************************/
...
@@ -71,9 +78,15 @@ public class CarHomePushService extends PushService{
...
@@ -71,9 +78,15 @@ public class CarHomePushService extends PushService{
//appkey
//appkey
pushRequest
.
setAppKey
(
appKey_ios_aliyun
);
pushRequest
.
setAppKey
(
appKey_ios_aliyun
);
//环境
//环境
pushRequest
.
setTestMode
(
testMode
);
pushRequest
.
setTestMode
(
testMode_aliyun_ios
);
//通知跳转
pushRequest
.
setType
(
type_ios_aliyun
);
Map
<
String
,
String
>
map
=
new
HashMap
();
//ios用于判断点击通知后跳转参数
map
.
put
(
"type"
,
type_ios_aliyun
);
map
.
put
(
"msgBody"
,
pushRequest
.
getMsgBody
());
//额外参数
pushRequest
.
setExtParametersMap
(
map
);
}
}
@Override
@Override
...
@@ -88,11 +101,16 @@ public class CarHomePushService extends PushService{
...
@@ -88,11 +101,16 @@ public class CarHomePushService extends PushService{
//appMasterSecret
//appMasterSecret
pushRequest
.
setAppMasterSecret
(
appMasterSecret_android_youmeng
);
pushRequest
.
setAppMasterSecret
(
appMasterSecret_android_youmeng
);
//环境
//环境
pushRequest
.
setTestMode
(
testMode
);
pushRequest
.
setTestMode
(
testMode
_youmeng_android
);
//AliasType
//AliasType
pushRequest
.
setAliasType
(
aliasType_android_youmeng
);
pushRequest
.
setAliasType
(
aliasType_android_youmeng
);
//通知跳转
//通知跳转
pushRequest
.
setActivity
(
activity_android_youmeng
);
pushRequest
.
setActivity
(
activity_android_youmeng
);
Map
<
String
,
String
>
map
=
new
HashMap
();
map
.
put
(
"msgBody"
,
pushRequest
.
getMsgBody
());
//额外参数
pushRequest
.
setExtParametersMap
(
map
);
}
}
@Override
@Override
...
...
src/test/java/com/glsx/modules/notify/controller/DeviceControllerTest.java
View file @
d8eaf6e
...
@@ -33,10 +33,11 @@ public class DeviceControllerTest {
...
@@ -33,10 +33,11 @@ public class DeviceControllerTest {
//pushRequest.setPlatformType(PushType.YOUMENG.getCode());
//pushRequest.setPlatformType(PushType.YOUMENG.getCode());
pushRequest
.
setDeviceType
(
"ANDROID"
);
pushRequest
.
setDeviceType
(
"ANDROID"
);
//推送别名参数
//推送别名参数
pushRequest
.
setAlias
(
"91712
432
"
);
pushRequest
.
setAlias
(
"91712
507
"
);
//通知参数
//通知参数
pushRequest
.
setTitle
(
"消息推送测试标题"
);
pushRequest
.
setTitle
(
"消息推送测试标题"
);
pushRequest
.
setBody
(
"内容test"
);
pushRequest
.
setBody
(
"内容test"
);
pushRequest
.
setMsgBody
(
"这是消息的内容"
);
BaseRequest
baseRequest
=
new
BaseRequest
();
BaseRequest
baseRequest
=
new
BaseRequest
();
BeanUtils
.
copyProperties
(
pushRequest
,
baseRequest
);
BeanUtils
.
copyProperties
(
pushRequest
,
baseRequest
);
...
@@ -67,7 +68,7 @@ public class DeviceControllerTest {
...
@@ -67,7 +68,7 @@ public class DeviceControllerTest {
//通知参数
//通知参数
pushRequest
.
setTitle
(
"这是消息推送测试标题"
);
pushRequest
.
setTitle
(
"这是消息推送测试标题"
);
pushRequest
.
setBody
(
"这是内容test"
);
pushRequest
.
setBody
(
"这是内容test"
);
pushRequest
.
setMsgBody
(
"这是消息的内容"
);
BaseRequest
baseRequest
=
new
BaseRequest
();
BaseRequest
baseRequest
=
new
BaseRequest
();
BeanUtils
.
copyProperties
(
pushRequest
,
baseRequest
);
BeanUtils
.
copyProperties
(
pushRequest
,
baseRequest
);
if
(
baseRequest
.
getDeviceType
().
equals
(
"ANDROID"
)){
if
(
baseRequest
.
getDeviceType
().
equals
(
"ANDROID"
)){
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment