Skip to content

Commit

Permalink
优化服务端的测试代码
Browse files Browse the repository at this point in the history
  • Loading branch information
taoweiji committed Jun 3, 2017
1 parent e23ad2b commit d19744c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@

public class GeTuiPushServerManager implements MixPushServerManager {
//定义常量, appId、appKey、masterSecret 采用本文档 "第二步 获取访问凭证 "中获得的应用配置
private static String appId = "51xb25cmJx9I28wet1Rtd5";
private static String appKey = "Wq0MtiYBdO7YwpTLbR8iI3";
private static String masterSecret = "W0EHO18Yk77sSLJxCvBlf4";
private static String url = "http://sdk.open.api.igexin.com/apiex.htm";
private String appId;
private String appKey;
private String masterSecret;
private String url;

public GeTuiPushServerManager(String appId, String appKey, String masterSecret, String url) {
this.appId = appId;
this.appKey = appKey;
this.masterSecret = masterSecret;
this.url = url;
}

@Override
public void sendMessageToAlias(List<String> alias, String messagePayload) throws IOException {
Expand Down Expand Up @@ -102,10 +109,11 @@ public void sendMessageToAll(String messagePayload) throws IOException, ParseExc
IPushResult ret = push.pushMessageToApp(message);
System.out.println("all:" + ret.getResponse().toString());
}
private NotificationTemplate getNotificationTemplate(String title, String description, String messagePayload){

private NotificationTemplate getNotificationTemplate(String title, String description, String messagePayload) {
JSONObject jsonObject = JSON.parseObject(messagePayload);
// 用于区分 通知和透传,因为个推Android是不支持区分,所以要自己实现
jsonObject.put("notify",1);
jsonObject.put("notify", 1);
messagePayload = jsonObject.toJSONString();
NotificationTemplate template = new NotificationTemplate();
template.setTransmissionContent(messagePayload);
Expand Down
21 changes: 0 additions & 21 deletions server/src/main/java/com/mixpush/server/MixMessage.java

This file was deleted.

6 changes: 2 additions & 4 deletions server/src/main/java/com/mixpush/server/MixPushServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
public class MixPushServer {
private static List<MixPushServerManager> managers = new ArrayList<>();

static {
managers.add(new MeizuPushServerManager(110697L,"ef7778880d264ec28a47399509974659"));
managers.add(new GeTuiPushServerManager());
managers.add(new MiPushServerManager("com.mixpush.demo","0Evhdw93wlSfAiZ3JEkCMA=="));

public static void addPushServerManager(MixPushServerManager serverManager){
managers.add(serverManager);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
* Created by Wiki on 2017/6/1.
*/
public class MixPushServerTest {
static {
MixPushServer.addPushServerManager(new MeizuPushServerManager(110697L,"ef7778880d264ec28a47399509974659"));
MixPushServer.addPushServerManager(new GeTuiPushServerManager("51xb25cmJx9I28wet1Rtd5","Wq0MtiYBdO7YwpTLbR8iI3","W0EHO18Yk77sSLJxCvBlf4","http://sdk.open.api.igexin.com/apiex.htm"));
MixPushServer.addPushServerManager(new MiPushServerManager("com.mixpush.demo","0Evhdw93wlSfAiZ3JEkCMA=="));
}

@Test
public void sendNotifyToAll() throws Exception {
Expand Down

0 comments on commit d19744c

Please sign in to comment.