增加消息功能key
This commit is contained in:
@@ -4,11 +4,13 @@ import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ruoyi.common.constant.AliKeyConfig;
|
||||
import com.ruoyi.common.core.domain.UmResp;
|
||||
import com.ruoyi.common.core.domain.entity.PushMsgInfo;
|
||||
import com.ruoyi.common.enums.DeviceTypeEnum;
|
||||
import com.ruoyi.common.utils.uuid.UUID;
|
||||
import com.ruoyi.system.config.push.AndroidNotification;
|
||||
import com.ruoyi.system.config.push.PushClient;
|
||||
import com.ruoyi.system.config.push.android.AndroidCustomizedcast;
|
||||
import com.ruoyi.system.config.push.ios.IOSCustomizedcast;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.http.Header;
|
||||
@@ -37,7 +39,7 @@ public class UmengConfig {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(UmengConfig.class);
|
||||
|
||||
private PushClient client = new PushClient();
|
||||
private final PushClient client = new PushClient();
|
||||
|
||||
public UmResp send(String token,String deviceTypeUp){
|
||||
String umAppkey = null;
|
||||
@@ -53,7 +55,7 @@ public class UmengConfig {
|
||||
//
|
||||
// }
|
||||
// //687b2df479267e0210b79b6f
|
||||
// String umAppkey = "687b2e1679267e0210b79b70";
|
||||
// String umAppkey = "68a99a66ec2b5b6f8825b8b1";
|
||||
// String appKey = "204918113";
|
||||
// String appSecret = "v4UrIhhLZlo0adpmevyCfvThGFbrRer0";
|
||||
// 下面的url要和阿里云云市场购买的商品对应
|
||||
@@ -103,6 +105,7 @@ public class UmengConfig {
|
||||
try {
|
||||
log.info("发送数据:{}",httpPost);
|
||||
CloseableHttpResponse response = httpclient.execute(httpPost);
|
||||
log.info("返回数据1:{}",response);
|
||||
String respStr = EntityUtils.toString(response.getEntity());
|
||||
log.info("返回数据:{}",respStr);
|
||||
return JSONUtil.toBean(respStr, UmResp.class);
|
||||
@@ -113,36 +116,66 @@ public class UmengConfig {
|
||||
}
|
||||
|
||||
|
||||
public void sendAndroidCustomizedcast() throws Exception {
|
||||
AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(AliKeyConfig.UMApp_AliKey,AliKeyConfig.UMApp_AliSecret);
|
||||
public void sendAndroidCustomizedcast(PushMsgInfo pushMsgInfo) throws Exception {
|
||||
// appAliKey: 204918113
|
||||
// appAliSecret: v4UrIhhLZlo0adpmevyCfvThGFbrRer0
|
||||
// AndroidCustomizedcast customizedcast = new AndroidCustomizedcast("68a9988ce563686f4288e26d","vxq4qfnb3jbb3jahrcxpbtpjgcuu7dtm");
|
||||
AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(AliKeyConfig.UMApp_Android_Key,AliKeyConfig.Android_SECRET);
|
||||
// TODO Set your alias here, and use comma to split them if there are multiple alias.
|
||||
// And if you have many alias, you can also upload a file containing these alias, then
|
||||
// use file_id to send customized notification.
|
||||
customizedcast.setAlias("alias", "alias_type");
|
||||
customizedcast.setTicker( "Android customizedcast ticker");
|
||||
customizedcast.setTitle( "中文的title");
|
||||
customizedcast.setText( "Android customizedcast text");
|
||||
customizedcast.setAlias(pushMsgInfo.getAlias(), pushMsgInfo.getAlias_type());
|
||||
customizedcast.setTicker(pushMsgInfo.getTicker());
|
||||
customizedcast.setTitle(pushMsgInfo.getTitle());
|
||||
customizedcast.setText(pushMsgInfo.getText());
|
||||
customizedcast.goAppAfterOpen();
|
||||
customizedcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
|
||||
// TODO Set 'production_mode' to 'false' if it's a test device.
|
||||
// For how to register a test device, please see the developer doc.
|
||||
customizedcast.setProductionMode();
|
||||
//厂商通道相关参数
|
||||
customizedcast.setChannelActivity("your channel activity");
|
||||
customizedcast.setChannelProperties("abc");
|
||||
// customizedcast.setChannelActivity("your channel activity");
|
||||
// customizedcast.setChannelProperties("abc");
|
||||
client.send(customizedcast);
|
||||
}
|
||||
|
||||
public void sendIOSCustomizedcast(PushMsgInfo pushMsgInfo) throws Exception {
|
||||
//App Key:68a99a66ec2b5b6f8825b8b1
|
||||
//App Master Secret:tjbflqx0eoqjixtyrtbh0zgijawmvxfe
|
||||
//IOSCustomizedcast customizedcast = new IOSCustomizedcast("68a99a66ec2b5b6f8825b8b1","tjbflqx0eoqjixtyrtbh0zgijawmvxfe");
|
||||
IOSCustomizedcast customizedcast = new IOSCustomizedcast(AliKeyConfig.UMApp_IOS_Key,AliKeyConfig.IOS_SECRET);
|
||||
// TODO Set your alias and alias_type here, and use comma to split them if there are multiple alias.
|
||||
// And if you have many alias, you can also upload a file containing these alias, then
|
||||
// use file_id to send customized notification.
|
||||
customizedcast.setAlias(pushMsgInfo.getAlias(), pushMsgInfo.getAlias_type());
|
||||
//customizedcast.setAlert("IOS 个性化测试");
|
||||
//alert的值设置为字典
|
||||
customizedcast.setAlert(pushMsgInfo.getTitle() , "" , pushMsgInfo.getText());
|
||||
customizedcast.setBadge( 0);
|
||||
customizedcast.setSound( "default");
|
||||
// TODO set 'production_mode' to 'true' if your app is under production mode
|
||||
customizedcast.setTestMode();
|
||||
client.send(customizedcast);
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws Exception {
|
||||
UmengConfig umengConfig = new UmengConfig();
|
||||
// System.out.println(DeviceTypeEnum.ANDROID.name());
|
||||
// UmResp sss1 = send("eyJvIjoiaU9TIiwiayI6ImJNSGJwMktVdjhVaE5zOW1wQWhwYlwvWCtVRTlqcnZKeXhjb091N3BDdVlqcHNEc2RKM3A2M0pJZ056U0JrdlY5UlFPSHo3U25ZMmNcL3ZpbUI3ZHN2THFwQXlkbmRJeDB4NHhLSytFR2pvVEF4eU1oUnpUVHlrNHYzZThCSjNIajJOamJoK0VPdUtRTXV3N2pnS0dIdHJoT3FJRFF4QXJ0NisrUTI1ODhhQWdEVnp5TUVZdmxpTFhKeDUwS1wvZWI5VjdSb1VoNkMzc2E5Mm1xcHI1S3FxMm9KZHk3THoyYkVPQUVnM1hvWHJWVl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;
|
||||
//
|
||||
// sss = "{\"success\":true,\"data\":{\"mobile\":\"18518753918\",\"score\":null,\"activeScore\":null,\"aesEncryptKey\":null},\"code\":2001,\"message\":\"gain mobile's result success\",\"requestId\":\"0E87E249-42A0-42C0-94D3-7424D45E571E\"}\n";
|
||||
//
|
||||
// UmResp ss = JSONUtil.toBean(sss, UmResp.class);
|
||||
// System.out.println(ss);
|
||||
//UmengConfig umengConfig = new UmengConfig();
|
||||
// PushMsgInfo pushMsgInfo = new PushMsgInfo();
|
||||
// pushMsgInfo.setText("test");
|
||||
// pushMsgInfo.setTitle("title");
|
||||
// pushMsgInfo.setAlias("13943965645");
|
||||
// //umengConfig.sendAndroidCustomizedcast(pushMsgInfo);
|
||||
// umengConfig.sendIOSCustomizedcast(pushMsgInfo);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user