diff --git a/doc/api.md b/doc/api.md
index 8a62311..b6fe054 100644
--- a/doc/api.md
+++ b/doc/api.md
@@ -48,6 +48,18 @@
|value|object|否|无|当 style = 1, 为大文本通知栏样式,类型为 string,内容会被通知栏以大文本的形式展示出来。支持 API 16 以上的 rom;
当 style = 2,为文本条目通知栏样式,类型为 json 对象,json 的每个 key 对应的 value 会被当作文本条目逐条展示。支持 API 16 以上的 rom;
当 style = 3,为大图片通知栏样式,类型为 string,可以是网络图片 url,或本地图片的 path,目前支持.jpg和.png后缀的图片。图片内容会被通知栏以大图片的形式展示出来。如果是 http/https 的url,会自动下载;如果要指定开发者准备的本地图片就填 sdcard 的相对路径。支持 API 16以上的 rom。|
|alertTYpe|int|否|-1|可选范围为 -1 ~ 7 ,对应 Notification.DEFAULT_ALL = -1 或者 Notification.DEFAULT_SOUND = 1, Notification.DEFAULT_VIBRATE = 2, Notification.DEFAULT_LIGHTS = 4 的任意 “or” 组合。默认按照 -1 处理。|
+***注:对于Android notification 其他参数,比如:uri_activity,uri_action等,可使用如下方式添加:***
+```
+// 创建android notification对象
+var androidObj = JPush.android('Hi,JPush', 'JPush Title', 1, {'key':'value'});
+// 新增参数:uri_activity, uri_action
+androidObj.android['uri_activity'] = 'xxx';
+androidObj.android['uri_action'] = 'xxx';
+```
+
+
+
+
**winphone(alert, title, openPage, extras)**
|参数|类型|必须|默认值|说明|
diff --git a/examples/DeviceAsyncExamples.js b/examples/DeviceAsyncExamples.js
index 7b5e54c..50806d0 100644
--- a/examples/DeviceAsyncExamples.js
+++ b/examples/DeviceAsyncExamples.js
@@ -26,3 +26,13 @@ client.getDeviceTagAlias('0900e8d85ef')
}).catch(function(err) {
console.log(err)
})
+
+async function getDeviceStatus() {
+ const resp = await client.getDeviceStatus(['171976fa8a8085fcdba']);
+ if (resp.err) {
+ console.log(resp.err.message)
+ } else {
+ console.log(resp.res);
+ }
+}
+getDeviceStatus();
diff --git a/examples/DeviceExample.js b/examples/DeviceExample.js
index 459d28e..26efd70 100644
--- a/examples/DeviceExample.js
+++ b/examples/DeviceExample.js
@@ -113,3 +113,16 @@ client.deleteAlias('alias2', null, function (err, res) {
console.log('success')
}
})
+
+/** 查询设备在线状态 */
+client.getDeviceStatus(["160a3797c80b688c24b"], function(err, res) {
+ if (err) {
+ if (err instanceof JPush.APIConnectionError) {
+ console.log(err.message)
+ } else if (err instanceof JPush.APIRequestError) {
+ console.log(err.message)
+ }
+ } else {
+ console.log(res);
+ }
+})
diff --git a/examples/ReportAsyncExample.js b/examples/ReportAsyncExample.js
new file mode 100644
index 0000000..3bcb461
--- /dev/null
+++ b/examples/ReportAsyncExample.js
@@ -0,0 +1,14 @@
+var JPush = require("../index.js").JPushAsync;
+var Conf = require("./Conf.js");
+
+var client = JPush.buildClient(Conf.appKey, Conf.masterSecret);
+
+async function getReportStatusMessage() {
+ const data = await client.getReportStatusMessage(23223422, ['24243242']);
+ if (data.err) {
+ console.log(data.err);
+ } else {
+ console.log(data.res);
+ }
+ }
+ getReportStatusMessage();
diff --git a/lib/JPush/JPush.js b/lib/JPush/JPush.js
index c49e149..ada6028 100644
--- a/lib/JPush/JPush.js
+++ b/lib/JPush/JPush.js
@@ -121,9 +121,9 @@ function getReportStatusMessage(msgId, registrationIds, date, callback) {
if (msgId == null) {
throw new JError.InvalidArgumentError('msgId is null!');
}
- if (typeof(msgId) != 'number') {
- throw new JError.InvalidArgumentError('msgId is not number type!');
- }
+ // if (typeof(msgId) != 'number') {
+ // throw new JError.InvalidArgumentError('msgId is not number type!');
+ // }
if (registrationIds == null) {
throw new JError.InvalidArgumentError('registrationIds is null!');
}
@@ -363,6 +363,22 @@ function batchPush(url, singlePayloads, callback) {
// 定时任务 end
+/**
+ * 获取用户在线状态(vip专属接口)
+ * https://docs.jiguang.cn//jpush/server/push/rest_api_v3_device/#vip
+ * @param {*} regIds 需要在线状态的用户 registration_id
+ * @param {*} callback
+ */
+function getDeviceStatus(regIds, callback) {
+ var json = {
+ "registration_ids": regIds
+ };
+
+ var url = HOST_NAME_SSL + DEVICE_PATH + '/status';
+ return _request(this, url, JSON.stringify(json), 'POST', callback);
+}
+
+
// Proxy start
// Proxy end
@@ -447,6 +463,7 @@ JPushClient.prototype.addRemoveDevicesFromTag = addRemoveDevicesFromTag
JPushClient.prototype.deleteTag = deleteTag
JPushClient.prototype.getAliasDeviceList = getAliasDeviceList
JPushClient.prototype.deleteAlias = deleteAlias
+JPushClient.prototype.getDeviceStatus = getDeviceStatus
JPushClient.prototype.validate = validate
JPushClient.prototype.getReportMessages = getReportMessages
JPushClient.prototype.getReportUsers = getReportUsers
diff --git a/lib/JPush/JPushAsync.js b/lib/JPush/JPushAsync.js
index 35076c1..346621c 100644
--- a/lib/JPush/JPushAsync.js
+++ b/lib/JPush/JPushAsync.js
@@ -116,25 +116,25 @@ async function getReportReceivedDetail(msgIds) {
return _request(this, url, null, 'GET')
}
-async function getReportStatusMessage(msgId, registrationIds, date) {
+function getReportStatusMessage(msgId, registrationIds, date) {
if (msgId == null) {
throw new JError.InvalidArgumentError('msgId is null!');
}
- if (typeof(msgId) != 'number') {
- throw new JError.InvalidArgumentError('msgId is not number type!');
- }
+
if (registrationIds == null) {
throw new JError.InvalidArgumentError('registrationIds is null!');
}
var json = {
- "msg_id": msgId,
+ "msg_id": msgId > Number.MAX_SAFE_INTEGER ? String(msgId) : msgId,
"registration_ids": registrationIds
};
if (date != null) {
json.date = date;
}
var url = REPORT_API_URL + REPORT_STATUS_MESSAGE;
- return _request(this, url, JSON.stringify(json), 'POST');
+ return _request(this, url, json, 'POST')
+ .then(res => ({ res }))
+ .catch(error => ({ err: error }));
}
async function getReportMessages(msgIds) {
@@ -312,6 +312,22 @@ async function getScheduleMsgIds (scheduleId, callback) {
// Proxy end
+/**
+ * 获取用户在线状态(vip专属接口)
+ * https://docs.jiguang.cn//jpush/server/push/rest_api_v3_device/#vip
+ * @param {*} regIds 需要在线状态的用户 registration_id
+ */
+function getDeviceStatus(regIds) {
+ var json = {
+ "registration_ids": regIds
+ };
+
+ var url = HOST_NAME_SSL + DEVICE_PATH + '/status';
+ return _request(this, url, json, 'POST')
+ .then(res => ({ res }))
+ .catch(error => ({ err: error }));
+}
+
async function _request (client, url, body, method, times = 1) {
if (client.isDebug) {
debug('Push URL :' + url)
@@ -369,6 +385,7 @@ JPushClient.prototype.getDeviceTagAlias = getDeviceTagAlias
JPushClient.prototype.updateDeviceTagAlias = updateDeviceTagAlias
JPushClient.prototype.getTagList = getTagList
JPushClient.prototype.isDeviceInTag = isDeviceInTag
+JPushClient.prototype.getDeviceStatus = getDeviceStatus
JPushClient.prototype.addRemoveDevicesFromTag = addRemoveDevicesFromTag
JPushClient.prototype.deleteTag = deleteTag
JPushClient.prototype.getAliasDeviceList = getAliasDeviceList