|
@@ -58,7 +58,7 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean
|
|
|
* @param content 消息内容
|
|
|
* @return json对象
|
|
|
*/
|
|
|
- private JSONObject generateJson(String[] alias, String alert, String content, String url,String contentType) {
|
|
|
+ private JSONObject generateJson(String[] alias, String alert, String content, String url,String sound) {
|
|
|
JSONObject json = new JSONObject();
|
|
|
JSONArray platform = new JSONArray();// 平台
|
|
|
platform.add("android");
|
|
@@ -83,7 +83,7 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean
|
|
|
|
|
|
JSONObject ios = new JSONObject();// ios通知内容
|
|
|
ios.put("alert", alert);
|
|
|
- ios.put("sound", "default");
|
|
|
+ ios.put("sound", sound);
|
|
|
ios.put("badge", "+1");
|
|
|
JSONObject ios_extras = new JSONObject();// ios额外参数
|
|
|
ios_extras.put("type", "infomation");
|
|
@@ -96,7 +96,7 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean
|
|
|
JSONObject message = new JSONObject();// 通知消息内容
|
|
|
message.put("title", alert);
|
|
|
message.put("msg_content", content);
|
|
|
- message.put("content_type",contentType);
|
|
|
+ message.put("content_type","text");
|
|
|
|
|
|
JSONObject options = new JSONObject();// 设置参数
|
|
|
options.put("time_to_live", this.time_to_live);
|
|
@@ -117,7 +117,7 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean
|
|
|
* @param alert 推送消息
|
|
|
* @param content 推送内容
|
|
|
*/
|
|
|
- private String push(String[] alias, String alert, String content, String url,String type,String contentType) {
|
|
|
+ private String push(String[] alias, String alert, String content, String url,String type,String sound) {
|
|
|
String base64_auth_string = "";
|
|
|
switch (type){
|
|
|
case "STUDENT":
|
|
@@ -131,7 +131,7 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean
|
|
|
break;
|
|
|
}
|
|
|
String authorization = "Basic " + base64_auth_string;
|
|
|
- return sendPostRequest(generateJson(alias, alert, content, url,contentType).toString(), authorization);
|
|
|
+ return sendPostRequest(generateJson(alias, alert, content, url,sound).toString(), authorization);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -177,9 +177,9 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean send(String subject, String content, String receiver, String url, String type,String contentType) throws IOException {
|
|
|
+ public boolean send(String subject, String content, String receiver, String url, String type,String sound) throws IOException {
|
|
|
String[] alias = { receiver };
|
|
|
- String result = this.push(alias, subject, content, url,type,contentType);
|
|
|
+ String result = this.push(alias, subject, content, url,type,sound);
|
|
|
JSONObject json = JSONObject.parseObject(result);
|
|
|
if (json.containsKey("error")) {
|
|
|
JSONObject jsonObject = json.getJSONObject("error");
|
|
@@ -189,8 +189,8 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean batchSend(String subject, String content, String[] receivers, String url, String type,String contentType) throws IOException {
|
|
|
- String result = this.push(receivers, subject, content, url,type,contentType);
|
|
|
+ public boolean batchSend(String subject, String content, String[] receivers, String url, String type,String sound) throws IOException {
|
|
|
+ String result = this.push(receivers, subject, content, url,type,sound);
|
|
|
JSONObject json = JSONObject.parseObject(result);
|
|
|
if (json.containsKey("error")) {
|
|
|
JSONObject jsonObject = json.getJSONObject("error");
|