package com.hxh.spring.test;
|
|
import com.alibaba.fastjson.JSONObject;
|
import org.junit.Test;
|
import org.yeshi.utils.push.entity.PushAppInfo;
|
import org.yeshi.utils.push.entity.PushMessage;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
//
|
//@RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试
|
//@ContextConfiguration(locations = {"classpath:spring.xml"})
|
//@WebAppConfiguration
|
public class PushTest {
|
|
private PushAppInfo createXiaoMiApp() {
|
PushAppInfo appInfo = new PushAppInfo("2882303761517505364", "5681750540364", "Zvpz4OyZNbhElUAy15cDLA==");
|
appInfo.setPackageName("com.doudou.ysvideo");
|
return appInfo;
|
}
|
|
private PushAppInfo createVIVOApp() {
|
PushAppInfo appInfo = new PushAppInfo("100061268", "e9add1dfed7086061119d407857628ef", "8e27162d-8d30-4e54-8da4-db4809c0bc7e");
|
return appInfo;
|
}
|
|
private PushAppInfo createOPPOApp() {
|
PushAppInfo appInfo = new PushAppInfo("", "9w8ke27Mlk8osgCoOkg4Ow8cg", "819d6B053dEDd3e83818a28Cf30d82D9");
|
return appInfo;
|
}
|
|
private PushAppInfo createMeiZuApp() {
|
PushAppInfo appInfo = new PushAppInfo("139085", "dc40ea74e19948a683cb1876d5a8813e", "6497adb8bde044c6a32c0a2766332ca3");
|
return appInfo;
|
}
|
|
private PushAppInfo createHuaWeiApp() {
|
PushAppInfo appInfo = new PushAppInfo("10409568", "", "ncqclliuf1ym2h8r1nwbkxbqe526shdb");
|
return appInfo;
|
}
|
|
private void push(PushMessage message) {
|
|
// try {
|
// HuaWeiPushUtil.pushNotificationByTokens(createHuaWeiApp(), message, Arrays.asList(new String[]{"IQAAAACy0fVvAADnONaCqn1HELeETVK2JtV2FdwWRlCbrK-gPBoIh2ZXk-qGgcUX8MHt9DYsOeiVKYItZMac3hm8wYacFKhQswAbdKTPU5m2EKl_Tw"}));
|
// } catch (Exception e) {
|
// e.printStackTrace();
|
// }
|
//
|
// try {
|
// OppoPushUtil.pushNotificationByRegIds(createOPPOApp(), message, Arrays.asList(new String[]{"CN_23c9bfc46fe4bf286ef9e1a2993e86f8"}));
|
// } catch (Exception e) {
|
// e.printStackTrace();
|
// }
|
//
|
// try {
|
// VIVOPushUtil.pushNotificationByRegIds(createVIVOApp(), message, Arrays.asList(new String[]{"16139879500386126892292"}));
|
// } catch (Exception e) {
|
// e.printStackTrace();
|
// }
|
|
// try {
|
// XiaoMiPushUtil.pushNotificationByRegIds(createXiaoMiApp(), message, Arrays.asList(new String[]{"H11kB/pDknkREeUlnWgTgNcOvJpKVruGptLo0f3RCi4Okqg6ZZjeuw6si8ltkfej"}));
|
// } catch (IOException e) {
|
// e.printStackTrace();
|
// }
|
|
// try {
|
// MeiZuPushUtil.pushNotificationByPushId(createMeiZuApp(), message, Arrays.asList(new String[]{"UCI4e0f4070047c4949057e76446d6474484500447b05"}));
|
// } catch (IOException e) {
|
// e.printStackTrace();
|
// } catch (MeiZuPushException e) {
|
// e.printStackTrace();
|
// }
|
}
|
|
|
@Test
|
public void pushVideo() {
|
Map<String, String> activityParams = new HashMap<>();
|
activityParams.put("activity", "com.weikou.beibeivideo.ui.media.VideoDetailActivity2");
|
JSONObject jumpParams = new JSONObject();
|
jumpParams.put("Id", "8219668");
|
jumpParams.put("Share", 0);
|
jumpParams.put("ThirdType", 0);
|
activityParams.put("params", jumpParams.toJSONString());
|
PushMessage message = new PushMessage("赘婿更新了。。。", "赘婿更新了,赶快看看把", "com.weikou.beibeivideo.ui.push.PushOpenClickActivity", "buwanpush", "com.huawei.codelabpush/deeplink", activityParams);
|
push(message);
|
}
|
|
@Test
|
public void pushWeb() {
|
Map<String, String> activityParams = new HashMap<>();
|
activityParams.put("activity", "com.weikou.beibeivideo.ui.mine.BrowserActivity");
|
JSONObject jumpParams = new JSONObject();
|
jumpParams.put("url", "http://www.baidu.com");
|
activityParams.put("params", jumpParams.toJSONString());
|
PushMessage message = new PushMessage("网页推送", "讲述了三个不同年龄、不同性格的女生因缘际会在一起创业的故事,在这条不被看好的创业之路上,她们终将学会,对鸟事一笑置之,不是认输,而是成长!", "com.weikou.beibeivideo.ui.push.PushOpenClickActivity", "buwanpush", "com.huawei.codelabpush/deeplink", activityParams);
|
message.setActivityScheme("buwanpush");
|
message.setActivityHostPath("com.huawei.codelabpush/deeplink");
|
push(message);
|
}
|
|
@Test
|
public void pushBaiChuan() {
|
Map<String, String> activityParams = new HashMap<>();
|
activityParams.put("type", "baichuan");
|
JSONObject jumpParams = new JSONObject();
|
jumpParams.put("url", "https://s.click.taobao.com/RD851ru");
|
activityParams.put("params", jumpParams.toJSONString());
|
PushMessage message = new PushMessage("百川推送", "讲述了三个不同年龄、不同性格的女生因缘际会在一起创业的故事,百川推送", "com.weikou.beibeivideo.ui.push.PushOpenClickActivity", "buwanpush", "com.huawei.codelabpush/deeplink", activityParams);
|
message.setActivityScheme("buwanpush");
|
message.setActivityHostPath("com.huawei.codelabpush/deeplink");
|
push(message);
|
}
|
|
|
}
|