Skip to content

Commit 72a5a0d

Browse files
author
Javen
committed
Example change to send notification by default.
Add default log4j properties.
1 parent e9b7e47 commit 72a5a0d

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

resources/jpush-api.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Only info for JPush API demo. No need for running.
2+
13

24
# This app is only used for API Test. Please don't modify it.
35
username=jpush_api_client

resources/log4j.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
log4j.rootLogger=DEBUG,CONSOLE
2+
3+
log4j.logger.org.eclipse.jetty=INFO
4+
5+
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
6+
log4j.appender.CONSOLE.Target=System.out
7+
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
8+
log4j.appender.CONSOLE.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{2}: %m%n

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
import cn.jpush.api.JPushClient;
77
import cn.jpush.api.common.DeviceEnum;
8-
import cn.jpush.api.push.CustomMessageParams;
98
import cn.jpush.api.push.MessageResult;
9+
import cn.jpush.api.push.NotificationParams;
1010
import cn.jpush.api.push.ReceiverTypeEnum;
1111
import cn.jpush.api.report.ReceivedsResult;
1212

@@ -17,10 +17,10 @@ public class JPushClientExample {
1717
private static final String appKey ="dd1066407b044738b6479275";
1818
private static final String masterSecret = "2b38ce69b1de2a7fa95706ea";
1919

20-
public static final String msgTitle = "Test from API example";
21-
public static final String msgContent = "Test Test";
22-
public static final String registrationID = "0900e8d85ef";
23-
public static final String tag = "tag_api";
20+
public static final String TITLE = "Test from API example";
21+
public static final String CONTENT = "Test Test";
22+
public static final String REGISTRATION_ID = "0900e8d85ef";
23+
public static final String TAG = "tag_api";
2424

2525
public static void main(String[] args) {
2626
testSend();
@@ -29,13 +29,13 @@ public static void main(String[] args) {
2929

3030
private static void testSend() {
3131
JPushClient jpushClient = new JPushClient(masterSecret, appKey, 0, DeviceEnum.Android, false);
32-
CustomMessageParams params = new CustomMessageParams();
32+
NotificationParams params = new NotificationParams();
3333
//params.setReceiverType(ReceiverTypeEnum.REGISTRATION_ID);
3434
//params.setReceiverValue(registrationID);
3535
params.setReceiverType(ReceiverTypeEnum.TAG);
36-
params.setReceiverValue(tag);
36+
params.setReceiverValue(TAG);
3737

38-
MessageResult msgResult = jpushClient.sendCustomMessage(msgTitle, msgContent, params, null);
38+
MessageResult msgResult = jpushClient.sendNotification(CONTENT, params, null);
3939
LOG.debug("responseContent - " + msgResult.responseResult.responseContent);
4040
if (msgResult.isResultOK()) {
4141
LOG.info("msgResult - " + msgResult);

0 commit comments

Comments
 (0)