File tree Expand file tree Collapse file tree 2 files changed +6
-9
lines changed
Expand file tree Collapse file tree 2 files changed +6
-9
lines changed Original file line number Diff line number Diff line change 44import org .slf4j .LoggerFactory ;
55
66import cn .jpush .api .JPushClient ;
7- import cn .jpush .api .push .PushClient ;
7+ import cn .jpush .api .push .PushResult ;
88import cn .jpush .api .push .model .PushPayload ;
99import 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 () {
Original file line number Diff line number Diff line change 1515 * Can be used directly.
1616 */
1717public 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 );
You can’t perform that action at this time.
0 commit comments