Skip to content

Commit e6595c7

Browse files
author
Javen
committed
1. Upgrade to slf4j-api-1.7.7 for libs/
2. Add log4j support jars to libs, and project build path. They are for example running. 3. Add a device example.
1 parent 6adae43 commit e6595c7

File tree

6 files changed

+29
-3
lines changed

6 files changed

+29
-3
lines changed

.classpath

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@
1212
</attributes>
1313
</classpathentry>
1414
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
15+
<classpathentry kind="lib" path="libs/log4j-1.2.17.jar"/>
16+
<classpathentry kind="lib" path="libs/slf4j-log4j12-1.7.7.jar"/>
1517
<classpathentry kind="output" path="target/classes"/>
1618
</classpath>

example/main/java/cn/jpush/api/examples/DevcieExample.java

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

66
import cn.jpush.api.JPushClient;
7+
import cn.jpush.api.common.resp.APIConnectionException;
8+
import cn.jpush.api.common.resp.APIRequestException;
9+
import cn.jpush.api.device.TagAliasResult;
710

811
public class DevcieExample {
912
protected static final Logger LOG = LoggerFactory.getLogger(DevcieExample.class);
@@ -16,9 +19,30 @@ public class DevcieExample {
1619
private static final String REGISTRATION_ID1 = "0900e8d85ef";
1720
private static final String REGISTRATION_ID2 = "0a04ad7d8b4";
1821

19-
private static JPushClient jpushClient = new JPushClient(masterSecret, appKey, 3);
20-
22+
private static JPushClient jpushClient = new JPushClient(masterSecret, appKey);
23+
2124
public static void main(String[] args) {
22-
25+
testGetDeviceTagAlias();
26+
}
27+
28+
public static void testGetDeviceTagAlias() {
29+
try {
30+
TagAliasResult result = jpushClient.getDeviceTagAlias(REGISTRATION_ID1);
31+
32+
LOG.info(result.alias);
33+
LOG.info(result.tags.toString());
34+
35+
} catch (APIConnectionException e) {
36+
LOG.error("Connection error. Should retry later. ", e);
37+
38+
} catch (APIRequestException e) {
39+
LOG.error("Error response from JPush server. Should review and fix it. ", e);
40+
LOG.info("HTTP Status: " + e.getStatus());
41+
LOG.info("Error Code: " + e.getErrorCode());
42+
LOG.info("Error Message: " + e.getErrorMessage());
43+
}
2344
}
45+
2446
}
47+
48+

libs/log4j-1.2.17.jar

478 KB
Binary file not shown.

libs/slf4j-api-1.7.5.jar

-25.5 KB
Binary file not shown.

libs/slf4j-api-1.7.7.jar

28.6 KB
Binary file not shown.

libs/slf4j-log4j12-1.7.7.jar

8.66 KB
Binary file not shown.

0 commit comments

Comments
 (0)