Skip to content

Commit ad4fdb8

Browse files
author
huanglh
committed
PC-5108 修复新生成JPushClient会默认访问公有云的问题
1 parent 9b1dc35 commit ad4fdb8

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/main/java/cn/jpush/api/push/PushClient.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public PushClient(String masterSecret, String appKey) {
5757
this(masterSecret, appKey, null, ClientConfig.getInstance());
5858
}
5959

60+
public PushClient(String masterSecret, String appKey,ClientConfig clientConfig){
61+
this(masterSecret,appKey,null,clientConfig);
62+
}
63+
6064
/**
6165
* This will be removed in the future. Please use ClientConfig{jiguang-common cn.jiguang.common.ClientConfig} instead of this constructor.
6266
*

src/main/java/cn/jpush/api/schedule/ScheduleClient.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class ScheduleClient {
2323
private String hostName;
2424
private String schedulePath;
2525

26+
private PushClient pushClient;
27+
2628
// If not present, true by default.
2729
private int apnsProduction;
2830

@@ -81,6 +83,8 @@ public ScheduleClient(String masterSecret, String appKey, HttpProxy proxy, Clien
8183
schedulePath = (String) conf.get(ClientConfig.SCHEDULE_PATH);
8284
apnsProduction = (Integer) conf.get(ClientConfig.APNS_PRODUCTION);
8385
timeToLive = (Long) conf.get(ClientConfig.TIME_TO_LIVE);
86+
//createSchedule接口需要用到这个类
87+
pushClient = new PushClient(masterSecret, appKey, ClientConfig.getInstance());
8488

8589
String authCode = ServiceHelper.getBasicAuthorization(appKey, masterSecret);
8690
this._httpClient = new NativeHttpClient(authCode, proxy, conf);
@@ -104,7 +108,6 @@ public ScheduleResult createSchedule(SchedulePayload payload, String masterSecre
104108
// 调用getCidList方法来获取cid并赋值到payload中
105109
String cid = payload.getCid();
106110
if (cid == null) {
107-
PushClient pushClient = new PushClient(masterSecret, appKey);
108111
CIDResult cidResult = pushClient.getCidList(1 , "schedule");
109112
payload.setCid(cidResult.cidlist.get(0));
110113
}

src/test/java/cn/jpush/api/schedule/ScheduleClientTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ public void testGetScheduleList() {
6060
* Method: deleteSchedule(String scheduleId)
6161
*/
6262
@Test
63-
public void testScheduleMethods(String masterSecret, String appKey) {
63+
public void testScheduleMethods() {
64+
String masterSecret = MASTER_SECRET;
65+
String appKey = APP_KEY;
6466
String name = "test_schedule";
6567
TriggerPayload trigger = TriggerPayload.newBuilder()
66-
.setSingleTime("2105-07-30 12:00:00")
68+
.setSingleTime("2022-07-30 12:00:00")
6769
.buildSingle();
6870

6971
PushPayload push = PushPayload.alertAll("test schedule");

0 commit comments

Comments
 (0)