Commit d8eaf6e7 by fz

1.车家智能平台,android于iOS的开发模式参数分离设置

2.接口添加消息内容参数,作为通知扩展参数
1 parent d055ffbe
......@@ -11,6 +11,8 @@ import com.glsx.modules.notify.model.BaseRequest;
import com.glsx.plat.core.web.R;
import com.google.gson.Gson;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -77,12 +79,13 @@ public class AliYunStrategy implements PushStrategy {
buildBaseRequest(pushRequest, request);
//IOS默认设置
//ios通知跳转
Map map=new HashMap();
map.put("type",request.getType());
String extParameters= JSON.toJSONString(map);
//通知的扩展属性
Map extParametersMap = request.getExtParametersMap();
if(MapUtils.isNotEmpty(extParametersMap)){
String extParameters= JSON.toJSONString(extParametersMap);
pushRequest.setIOSExtParameters(extParameters);
}
//设置开发环境
pushRequest.setIOSApnsEnv(request.getTestMode());
return sendRequest(pushRequest);
......
......@@ -2,6 +2,8 @@ package com.glsx.modules.notify.model;
import lombok.Data;
import java.util.Map;
@Data
public class BaseRequest {
......@@ -84,7 +86,12 @@ public class BaseRequest {
private String activity;
/**
* 点击通知后跳转,ios相关为type值
* 通知携带额外参数值,此处为消息内容
*/
private String msgBody;
/**
* 通知的扩展属性
*/
private String type;
private Map<String,String> extParametersMap;
}
......@@ -18,4 +18,7 @@ public class NotifyReqParam {
@ApiModelProperty(value = "Android/iOS推送时的消息/通知内容,推送的内容大小是有限制的",required = true)
private String body;
@ApiModelProperty(value = "消息内容",required = true)
private String msgBody;
}
package com.glsx.modules.notify.push;
import com.alibaba.fastjson.JSON;
import com.glsx.modules.notify.model.BaseRequest;
import com.glsx.modules.notify.push.android.AndroidCustomizedcast;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
@Service
@Slf4j
public class BroadCastService {
@Autowired
private PushClient client;
......@@ -27,6 +33,19 @@ public class BroadCastService {
//通知文字描述
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
String activity = baseRequest.getActivity();
if (StringUtils.isEmpty(activity))
......
......@@ -8,6 +8,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
@Service
@Slf4j
public class CarHomePushService extends PushService{
......@@ -16,8 +19,12 @@ public class CarHomePushService extends PushService{
/**
* DEV表示开发环境,PRODUCT表示生产环境
*/
@Value("${youmeng.carhome.testMode}")
private String testMode;
@Value("${youmeng.carhome.android.testMode}")
private String testMode_youmeng_android;
@Value("${aliyun.carhome.ios.testMode}")
private String testMode_aliyun_ios;
/************************ android配置 ************************/
......@@ -71,9 +78,15 @@ public class CarHomePushService extends PushService{
//appkey
pushRequest.setAppKey(appKey_ios_aliyun);
//环境
pushRequest.setTestMode(testMode);
//通知跳转
pushRequest.setType(type_ios_aliyun);
pushRequest.setTestMode(testMode_aliyun_ios);
Map<String,String> map=new HashMap();
//ios用于判断点击通知后跳转参数
map.put("type",type_ios_aliyun);
map.put("msgBody",pushRequest.getMsgBody());
//额外参数
pushRequest.setExtParametersMap(map);
}
@Override
......@@ -88,11 +101,16 @@ public class CarHomePushService extends PushService{
//appMasterSecret
pushRequest.setAppMasterSecret(appMasterSecret_android_youmeng);
//环境
pushRequest.setTestMode(testMode);
pushRequest.setTestMode(testMode_youmeng_android);
//AliasType
pushRequest.setAliasType(aliasType_android_youmeng);
//通知跳转
pushRequest.setActivity(activity_android_youmeng);
Map<String,String> map=new HashMap();
map.put("msgBody",pushRequest.getMsgBody());
//额外参数
pushRequest.setExtParametersMap(map);
}
@Override
......
......@@ -33,10 +33,11 @@ public class DeviceControllerTest {
//pushRequest.setPlatformType(PushType.YOUMENG.getCode());
pushRequest.setDeviceType("ANDROID");
//推送别名参数
pushRequest.setAlias("91712432");
pushRequest.setAlias("91712507");
//通知参数
pushRequest.setTitle("消息推送测试标题");
pushRequest.setBody("内容test");
pushRequest.setMsgBody("这是消息的内容");
BaseRequest baseRequest = new BaseRequest();
BeanUtils.copyProperties(pushRequest,baseRequest);
......@@ -67,7 +68,7 @@ public class DeviceControllerTest {
//通知参数
pushRequest.setTitle("这是消息推送测试标题");
pushRequest.setBody("这是内容test");
pushRequest.setMsgBody("这是消息的内容");
BaseRequest baseRequest = new BaseRequest();
BeanUtils.copyProperties(pushRequest,baseRequest);
if (baseRequest.getDeviceType().equals("ANDROID")){
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!