|
@@ -59,42 +59,20 @@ public class PushUtil {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
if (ret.getResponse().get("result").toString().equals("ok")) {
|
|
|
+ System.out.println("消息推送:" + true);
|
|
|
return true;
|
|
|
}
|
|
|
System.out.println("消息推送:" + ret.getResponse().toString());
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
- public static void asd(){
|
|
|
- IGtPush push = new IGtPush(host, appKey, masterSecret);
|
|
|
-
|
|
|
- TransmissionTemplate t = new TransmissionTemplate();
|
|
|
- t.setAppId(appId);
|
|
|
- t.setAppkey(appKey);
|
|
|
- t.setTransmissionContent("{title:\"标题\",content:\"内容\",payload:\"自定义数据\"}");
|
|
|
- t.setTransmissionType(1);
|
|
|
-
|
|
|
-
|
|
|
- List<String> appIds = new ArrayList<String>();
|
|
|
- appIds.add(appId);
|
|
|
-
|
|
|
- // 定义"AppMessage"类型消息对象,设置消息内容模板、发送的目标App列表、是否支持离线发送、以及离线消息有效期(单位毫秒)
|
|
|
- AppMessage message = new AppMessage();
|
|
|
- message.setData(t);
|
|
|
- message.setAppIdList(appIds);
|
|
|
- message.setOffline(true);
|
|
|
- message.setOfflineExpireTime(1000 * 600);
|
|
|
-
|
|
|
- IPushResult ret = push.pushMessageToApp(message);
|
|
|
- System.out.println(ret.getResponse().toString());
|
|
|
- }
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
List<String>list=new ArrayList<>();
|
|
|
list.add("88d26b3633ca7d622704b473f6331487");
|
|
|
list.add("4c5889ce0d7594141127eacb697b8007");
|
|
|
+ //list.add("42a9c3372a60f1ccffe639520b421b07");
|
|
|
boolean s = sendMessage("家族通知", "余东申请加入", list);
|
|
|
- System.out.println("ssss:" + s);
|
|
|
///asd();
|
|
|
}
|
|
|
|
|
@@ -116,7 +94,7 @@ public class PushUtil {
|
|
|
style.setChannelLevel(3); //设置通知渠道重要性
|
|
|
template.setStyle(style);
|
|
|
|
|
|
- template.setTransmissionType(1); // 透传消息接受方式设置,1:立即启动APP,2:客户端收到消息后需要自行处理
|
|
|
+ template.setTransmissionType(2); // 透传消息接受方式设置,1:立即启动APP,2:客户端收到消息后需要自行处理
|
|
|
JSONObject obj=new JSONObject();
|
|
|
obj.put("title",title);
|
|
|
obj.put("text",text);
|