Skip to content

Commit fa8e47c

Browse files
author
Javen
committed
Improve example .
1 parent 34becb2 commit fa8e47c

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/cn/jpush/api/examples/JPushClientExample.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import org.slf4j.LoggerFactory;
55

66
import cn.jpush.api.JPushClient;
7-
import cn.jpush.api.push.PushClient;
7+
import cn.jpush.api.push.PushResult;
88
import cn.jpush.api.push.model.PushPayload;
99
import cn.jpush.api.report.ReceivedsResult;
1010

@@ -27,14 +27,12 @@ public static void main(String[] args) {
2727
}
2828

2929
private static void testSendNotification() {
30-
// Just for test
31-
PushClient.HOST_NAME_SSL = "https://api.jpush.cn:19688";
32-
3330
JPushClient jpushClient = new JPushClient(masterSecret, appKey);
3431
PushPayload payload = PushPayload.notificationAlertAll(CONTENT);
3532
LOG.info("Paylaod JSON - " + payload.toString());
3633

37-
jpushClient.sendPush(payload);
34+
PushResult result = jpushClient.sendPush(payload);
35+
LOG.debug(result.toString());
3836
}
3937

4038
private static void testSendMesasge() {

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515
* Can be used directly.
1616
*/
1717
public class PushClient extends BaseHttpClient {
18-
public static String HOST_NAME_SSL = "https://api.jpush.cn";
18+
private static String HOST_NAME_SSL = "https://api.jpush.cn";
1919
private static final String PUSH_PATH = "/v3/push";
2020

21-
private static final String PUSH_URL = HOST_NAME_SSL + PUSH_PATH;
22-
2321
// The API secret of the appKey. Please get it from JPush Web Portal
2422
private final String _masterSecret;
2523

@@ -59,7 +57,8 @@ public PushResult sendPush(PushPayload pushPayload) {
5957
pushPayload.resetOptionsApnsProduction(_apnsProduction);
6058
}
6159

62-
ResponseResult response = sendPost(PUSH_URL, pushPayload.toString(), _authCode);
60+
String url = HOST_NAME_SSL + PUSH_PATH;
61+
ResponseResult response = sendPost(url, pushPayload.toString(), _authCode);
6362
PushResult pushResult = null;
6463
if (response.responseCode == RESPONSE_OK) {
6564
pushResult = _gson.fromJson(response.responseContent, PushResult.class);

0 commit comments

Comments
 (0)