forked from jpush/jpush-api-java-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJPushClient.java
More file actions
67 lines (58 loc) · 2.05 KB
/
JPushClient.java
File metadata and controls
67 lines (58 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package cn.jpush.api;
import cn.jpush.api.push.PushClient;
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.report.ReceivedsResult;
import cn.jpush.api.report.ReportClient;
/**
* The overall entrance of JPush API library.
*/
public class JPushClient {
private final PushClient _pushClient;
private final ReportClient _reportClient;
/**
* Create a JPush Client.
*
* @param masterSecret API access secret of the appKey.
* @param appKey The KEY of one application on JPush.
*/
public JPushClient(String masterSecret, String appKey) {
_pushClient = new PushClient(masterSecret, appKey);
_reportClient = new ReportClient(masterSecret, appKey);
}
/**
* Create a JPush Client with global settings.
*
* If you want different settings from default globally, this constructor is what you needed.
*
* @param masterSecret API access secret of the appKey.
* @param appKey The KEY of one application on JPush.
* @param apnsProduction Global APNs environment setting. It will override PushPayload Options.
* @param timeToLive Global time_to_live setting. It will override PushPayload Options.
*/
public JPushClient(String masterSecret, String appKey, boolean apnsProduction, long timeToLive) {
_pushClient = new PushClient(masterSecret, appKey, apnsProduction, timeToLive);
_reportClient = new ReportClient(masterSecret, appKey);
}
/**
* Send a push
*
* @param pushPayload payload of a push.
* @return PushResult. Can be printed to a JSON.
*/
public PushResult sendPush(PushPayload pushPayload) {
return _pushClient.sendPush(pushPayload);
}
public PushResult sendPush(String payloadString) {
return _pushClient.sendPush(payloadString);
}
/**
* Get received report.
*
* @param msgIds 100 msgids to batch getting is supported.
* @return ReceivedResult. Can be printed to JSON.
*/
public ReceivedsResult getReportReceiveds(String msgIds) {
return _reportClient.getReceiveds(msgIds);
}
}