Skip to content

Commit a87b5d0

Browse files
author
zhengjh
committed
* 推送API,Notification里Android增加channel_id
* 增加批量单推接口 * 增加接口: 送达统计详情(新)/v3/received/detail * 增加接口: 送达状态查询 /v3/status/message * 增加接口: 消息统计详情(VIP 专属接口,新)/v3/messages/detail
1 parent 9043048 commit a87b5d0

16 files changed

+256
-50
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,5 @@ typings/
9494

9595
\.idea/
9696
package-lock.json
97+
/examples/Conf.js
98+
/test/BaseTest.js

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ client.push().setPlatform('ios', 'android')
6161
```js
6262
// 在构建 JPushClient 对象的时候, 指定 isDebug 参数。
6363
var client = JPush.buildClient({
64-
appKey:'47a3ddda34b2602fa9e17c01',
65-
masterSecret:'d94f733358cca97b18b2cb98',
64+
appKey:'your appKey',
65+
masterSecret:'your masterSecret',
6666
isDebug:false
6767
});
6868
// or
69-
var client = JPush.buildClient('47a3ddda34b2602fa9e17c01', 'd94f733358cca97b18b2cb98', null, false);
69+
var client = JPush.buildClient('your appKey', 'your masterSecret', null, false);
7070
```
7171

7272
> 目前使用了 debug 模块来控制日志输出,若要查看 JPush 的相关日志信息,请先配置 DEBUG 环境变量 'jpush'。

examples/BatchPushExample.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var JPush = require("../index.js").JPush;
2+
var Conf = require("./Conf.js");
3+
4+
console.log(Conf.appKey);
5+
console.log(Conf.masterSecret);
6+
var client = JPush.buildClient(Conf.appKey, Conf.masterSecret);
7+
console.log(client.appkey);
8+
console.log(client.masterSecret);
9+
10+
var singlePayloads = [
11+
{"platform":"all", "target":"regid1", "notification":{"alert":"alert title"}},
12+
{"platform":"all", "target":"regid2", "notification":{"alert":"alert title"}},
13+
];
14+
15+
client.batchPushByRegid(singlePayloads, function(err, res) {
16+
console.log(err);
17+
console.log(res);
18+
});

examples/Conf.js.example

Whitespace-only changes.

examples/DeviceAsyncExamples.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var JPush = require("../index.js").JPushAsync;
2+
var Conf = require("./Conf.js");
23

3-
var client = JPush.buildClient('a1703c14b186a68a66ef86c1', '9dabdf8bb704b421759cb49c')
4+
var client = JPush.buildClient(Conf.appKey, Conf.masterSecret);
45

56
async function fun() {
67
try {

examples/DeviceExample.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var JPush = require("../index.js").JPush;
2+
var Conf = require("./Conf.js");
23

3-
var client = JPush.buildClient('a1703c14b186a68a66ef86c1', '9dabdf8bb704b421759cb49c')
4+
var client = JPush.buildClient(Conf.appKey, Conf.masterSecret);
45

56
client.getDeviceTagAlias('0900e8d85ef', function (err, res) {
67
if (err) {

examples/PushAsyncExample.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
var JPush = require("../index.js").JPushAsync;
2-
var client = JPush.buildClient('a1703c14b186a68a66ef86c1', '9dabdf8bb704b421759cb49c')
2+
var Conf = require("./Conf.js");
3+
4+
var client = JPush.buildClient(Conf.appKey, Conf.masterSecret);
35

46
// 使用 proxy
5-
// var client = JPush.buildClient('a1703c14b186a68a66ef86c1', '9dabdf8bb704b421759cb49c', null, null, null,'http://192.168.8.236:3128')
7+
// var client = JPush.buildClient(Conf.appKey, Conf.masterSecret, null, null, null,'http://192.168.8.236:3128')
68

79
// easy push.
810
client.push().setPlatform(JPush.ALL)

examples/PushExample.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
var JPush = require("../index.js").JPush;
2-
var client = JPush.buildClient('a1703c14b186a68a66ef86c1', '9dabdf8bb704b421759cb49c')
2+
var Conf = require("./Conf.js");
3+
4+
var client = JPush.buildClient(Conf.appKey, Conf.masterSecret);
35

46
// 使用 proxy
5-
// var client = JPush.buildClient('a1703c14b186a68a66ef86c1', '9dabdf8bb704b421759cb49c', null, null, null,'http://192.168.8.236:3128')
7+
// var client = JPush.buildClient(Conf.appKey, Conf.masterSecret, null, null, null,'http://192.168.8.236:3128')
68

79
// easy push.
810
client.push().setPlatform(JPush.ALL)

examples/ReportExample.js

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,41 @@
11
var JPush = require("../index.js").JPush;
2+
var Conf = require("./Conf.js");
23

3-
var client = JPush.buildClient('96261ea4bcaae3f4a167a495', 'db1abbffbb619458b7785164')
4+
var client = JPush.buildClient(Conf.appKey, Conf.masterSecret);
45

5-
client.getReportReceiveds('746522674,344076897', function (err, res) {
6-
if (err) {
7-
if (err instanceof JPush.APIConnectionError) {
8-
console.log(err.message)
9-
// Response Timeout means your request to the server may have already received,
10-
// please check whether or not to push
11-
console.log(err.isResponseTimeout)
12-
} else if (err instanceof JPush.APIRequestError) {
13-
console.log(err.message)
6+
function getReportReceiveds() {
7+
client.getReportReceiveds('746522674,344076897', function (err, res) {
8+
if (err) {
9+
if (err instanceof JPush.APIConnectionError) {
10+
console.log(err.message)
11+
// Response Timeout means your request to the server may have already received,
12+
// please check whether or not to push
13+
console.log(err.isResponseTimeout)
14+
} else if (err instanceof JPush.APIRequestError) {
15+
console.log(err.message)
16+
}
17+
} else {
18+
for (var i = 0; i < res.length; i++) {
19+
console.log(res[i].android_received)
20+
console.log(res[i].ios_apns_sent)
21+
console.log(res[i].msg_id)
22+
console.log('------------')
23+
}
1424
}
15-
} else {
16-
for (var i = 0; i < res.length; i++) {
17-
console.log(res[i].android_received)
18-
console.log(res[i].ios_apns_sent)
19-
console.log(res[i].msg_id)
20-
console.log('------------')
21-
}
22-
}
25+
});
26+
}
27+
28+
client.getReportReceivedDetail('746522674,344076897', function(err, res) {
29+
console.log(err);
30+
console.log(res);
31+
})
32+
33+
client.getReportStatusMessage(746522674, ['regid1', 'regid2'], null, function(err, res) {
34+
console.log(err);
35+
console.log(res);
36+
})
37+
38+
client.getReportMessagesDetail('746522674,344076897', function(err, res) {
39+
console.log(err);
40+
console.log(res);
2341
})

examples/ScheduleExample.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
var JPush = require("../index.js").JPush;
2-
var client = JPush.buildClient('96261ea4bcaae3f4a167a495', 'db1abbffbb619458b7785164')
2+
var Conf = require("./Conf.js");
3+
4+
var client = JPush.buildClient(Conf.appKey, Conf.masterSecret);
35

46
// 设置定时任务。
57
client.push().setPlatform(JPush.ALL)

0 commit comments

Comments
 (0)