Skip to content

Commit b9f0a2a

Browse files
committed
Update example
1 parent e7ac599 commit b9f0a2a

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<attribute name="maven.pomderived" value="true"/>
3030
</attributes>
3131
</classpathentry>
32-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
32+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
3333
<attributes>
3434
<attribute name="maven.pomderived" value="true"/>
3535
</attributes>

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

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cn.jpush.api.examples;
22

3+
import java.util.HashSet;
34
import java.util.Map;
45

56
import org.slf4j.Logger;
@@ -15,19 +16,37 @@
1516
public class DeviceExample {
1617
protected static final Logger LOG = LoggerFactory.getLogger(DeviceExample.class);
1718

18-
private static final String appKey = "dd1066407b044738b6479275";
19-
private static final String masterSecret = "e8cc9a76d5b7a580859bcfa7";
19+
private static final String appKey = "7b4b94cca0d185d611e53cca";
20+
private static final String masterSecret = "860803cf613ed54aa3b941a8";
2021
private static final String TAG1 = "tag1";
2122
private static final String ALIAS1 = "alias1";
2223
private static final String ALIAS2 = "alias2";
23-
private static final String REGISTRATION_ID1 = "0900e8d85ef";
24+
private static final String REGISTRATION_ID1 = "160a3797c856951a397";
2425
private static final String REGISTRATION_ID2 = "0a04ad7d8b4";
2526

2627
private static JPushClient jpushClient = new JPushClient(masterSecret, appKey);
2728

2829
public static void main(String[] args) {
29-
testGetDeviceTagAlias();
30+
// testGetDeviceTagAlias();
3031
// testGetUserOnlineStatus();
32+
testUpdateDeviceTagAlias();
33+
}
34+
35+
public static void testUpdateDeviceTagAlias() {
36+
HashSet<String> tagSet = new HashSet<String>();
37+
tagSet.add("hhh");
38+
try {
39+
DefaultResult result = jpushClient.updateDeviceTagAlias(REGISTRATION_ID1, null, tagSet, null);
40+
LOG.info("Got result " + result);
41+
} catch (APIConnectionException e) {
42+
LOG.error("Connection error. Should retry later. ", e);
43+
44+
} catch (APIRequestException e) {
45+
LOG.error("Error response from JPush server. Should review and fix it. ", e);
46+
LOG.info("HTTP Status: " + e.getStatus());
47+
LOG.info("Error Code: " + e.getErrorCode());
48+
LOG.info("Error Message: " + e.getErrorMessage());
49+
}
3150
}
3251

3352
public static void testGetDeviceTagAlias() {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ public class PushExample {
5050
public static void main(String[] args) {
5151
// testSendPushWithCustomConfig();
5252
// testSendIosAlert();
53-
testSendPush();
53+
// testSendPush();
5454
// testGetCidList();
5555
// testSendPushes();
5656
// testSendPush_fromJSON();
5757
// testSendPushWithCallback();
58+
testSendPushWithCid();
5859
}
5960

6061
// 使用 NettyHttpClient 异步接口发送请求
@@ -353,7 +354,7 @@ public static PushPayload buildPushObject_all_tag_not() {
353354
public static PushPayload buildPushObject_android_cid() {
354355
return PushPayload.newBuilder()
355356
.setPlatform(Platform.android())
356-
.setAudience(Audience.registrationId("18071adc030dcba91c0"))
357+
.setAudience(Audience.registrationId("1507bfd3f79558957de"))
357358
.setNotification(Notification.alert(ALERT))
358359
.setCid("cid")
359360
.build();

0 commit comments

Comments
 (0)